Search in sources :

Example 1 with ApplicationProperties

use of org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties in project storm by apache.

the class BinaryEventDataScheme method deserialize.

@Override
public List<Object> deserialize(Message message) {
    final List<Object> fieldContents = new ArrayList<Object>();
    Map metaDataMap = new HashMap();
    byte[] messageData = new byte[0];
    for (Section section : message.getPayload()) {
        if (section instanceof Data) {
            Data data = (Data) section;
            messageData = data.getValue().getArray();
        } 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)

Example 2 with ApplicationProperties

use of org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties 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 ApplicationProperties

use of org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testApplicationPropertiesConversion.

public void testApplicationPropertiesConversion() {
    Map<String, Object> properties = new HashMap<>();
    properties.put("testProperty1", "testProperty1Value");
    properties.put("intProperty", 1);
    ApplicationProperties applicationProperties = new ApplicationProperties(properties);
    Message_1_0 message = createTestMessage(applicationProperties);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    final Map<String, Object> headers = FieldTable.convertToMap(convertedProperties.getHeaders());
    assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
Also used : HashMap(java.util.HashMap) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Example 4 with ApplicationProperties

use of org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testApplicationPropertiesConversionWhenKeyLengthExceeds255.

public void testApplicationPropertiesConversionWhenKeyLengthExceeds255() {
    Map<String, Object> properties = Collections.singletonMap("testProperty-" + generateLongString(), "testValue");
    ApplicationProperties applicationProperties = new ApplicationProperties(properties);
    Message_1_0 message = createTestMessage(applicationProperties);
    try {
        _messageConverter.convert(message, _namedAddressSpace);
        fail("Exception is expected");
    } catch (MessageConversionException e) {
    // pass
    }
}
Also used : MessageConversionException(org.apache.qpid.server.protocol.converter.MessageConversionException) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) Matchers.anyString(org.mockito.Matchers.anyString) AMQShortString(org.apache.qpid.server.protocol.v0_8.AMQShortString)

Example 5 with ApplicationProperties

use of org.apache.qpid.amqp_1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.

the class PropertyConverter_1_0_to_0_8Test method testCreationTimeConversion.

public void testCreationTimeConversion() {
    final long timestamp = System.currentTimeMillis() - 10000;
    final long arrivalTime = timestamp + 1;
    Properties properties = new Properties();
    properties.setCreationTime(new Date(timestamp));
    Message_1_0 message = createTestMessage(new Header(), new DeliveryAnnotations(Collections.emptyMap()), new MessageAnnotations(Collections.emptyMap()), properties, new ApplicationProperties(Collections.emptyMap()), arrivalTime);
    final AMQMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    BasicContentHeaderProperties convertedProperties = convertedMessage.getContentHeaderBody().getProperties();
    assertEquals("Unexpected timestamp", timestamp, convertedProperties.getTimestamp());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) BasicContentHeaderProperties(org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties) Date(java.util.Date) AMQMessage(org.apache.qpid.server.protocol.v0_8.AMQMessage)

Aggregations

ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)21 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)15 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)13 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)13 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)12 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)10 Matchers.anyString (org.mockito.Matchers.anyString)10 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)9 Date (java.util.Date)8 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)8 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)8 HashMap (java.util.HashMap)7 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)6 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)5 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)5 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)5 ArrayList (java.util.ArrayList)3 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)3 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)3 Map (java.util.Map)2