Search in sources :

Example 1 with AmqpValue

use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project storm by apache.

the class StringEventDataScheme method deserialize.

@Override
public List<Object> deserialize(Message message) {
    final List<Object> fieldContents = new ArrayList<Object>();
    for (Section section : message.getPayload()) {
        if (section instanceof Data) {
            Data data = (Data) section;
            fieldContents.add(new String(data.getValue().getArray()));
        } else if (section instanceof AmqpValue) {
            AmqpValue amqpValue = (AmqpValue) section;
            fieldContents.add(amqpValue.getValue().toString());
        }
    }
    return fieldContents;
}
Also used : ArrayList(java.util.ArrayList) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) Section(org.apache.qpid.amqp_1_0.type.Section) AmqpValue(org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)

Example 2 with AmqpValue

use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project storm by apache.

the class EventDataScheme method deserialize.

@Override
public List<Object> deserialize(Message message) {
    final List<Object> fieldContents = new ArrayList<Object>();
    Map metaDataMap = new HashMap();
    String messageData = "";
    for (Section section : message.getPayload()) {
        if (section instanceof Data) {
            Data data = (Data) section;
            messageData = new String(data.getValue().getArray());
        } else if (section instanceof AmqpValue) {
            AmqpValue amqpValue = (AmqpValue) section;
            messageData = amqpValue.getValue().toString();
        } else if (section instanceof ApplicationProperties) {
            final ApplicationProperties applicationProperties = (ApplicationProperties) section;
            metaDataMap = applicationProperties.getValue();
        }
    }
    fieldContents.add(messageData);
    fieldContents.add(metaDataMap);
    return fieldContents;
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) ApplicationProperties(org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties) Data(org.apache.qpid.amqp_1_0.type.messaging.Data) Map(java.util.Map) HashMap(java.util.HashMap) Section(org.apache.qpid.amqp_1_0.type.Section) AmqpValue(org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)

Example 3 with AmqpValue

use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithContentType.

public void testAmqpValueWithNullWithContentType() throws Exception {
    Properties properties = new Properties();
    final String mimeType = "foo/bar";
    properties.setContentType(Symbol.valueOf(mimeType));
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(properties, amqpValue.createEncodingRetainingSection());
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", mimeType, convertedMessage.getMessageHeader().getMimeType());
    assertNull("Unexpected content", convertedMessage.getMessageBody());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 4 with AmqpValue

use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithUnknownMessageAnnotation.

public void testAmqpValueWithNullWithUnknownMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), amqpValue.createEncodingRetainingSection());
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
    assertNull("Unexpected content", convertedMessage.getMessageBody());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Example 5 with AmqpValue

use of org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue in project qpid-broker-j by apache.

the class MessageConverter_v1_0_to_InternalTest method testAmqpValueWithNullWithBytesMessageAnnotation.

public void testAmqpValueWithNullWithBytesMessageAnnotation() throws Exception {
    final Object expected = null;
    final AmqpValue amqpValue = new AmqpValue(expected);
    Message_1_0 sourceMessage = createTestMessage(BYTE_MESSAGE_MESSAGE_ANNOTATION, amqpValue.createEncodingRetainingSection());
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", "application/octet-stream", convertedMessage.getMessageHeader().getMimeType());
    assertNull("Unexpected content", convertedMessage.getMessageBody());
}
Also used : InternalMessage(org.apache.qpid.server.message.internal.InternalMessage) NamedAddressSpace(org.apache.qpid.server.model.NamedAddressSpace) AmqpValue(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)

Aggregations

AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)57 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)55 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)40 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)21 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)17 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)17 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)15 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)11 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)10 LinkedHashMap (java.util.LinkedHashMap)8 HashMap (java.util.HashMap)7 Map (java.util.Map)7 ArrayList (java.util.ArrayList)6 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)6 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)6 JmsMapMessageToMap (org.apache.qpid.server.typedmessage.mimecontentconverter.JmsMapMessageToMap)6 MapToJmsMapMessage (org.apache.qpid.server.typedmessage.mimecontentconverter.MapToJmsMapMessage)4 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)3 Section (org.apache.qpid.amqp_1_0.type.Section)2 AmqpValue (org.apache.qpid.amqp_1_0.type.messaging.AmqpValue)2