Search in sources :

Example 1 with ApplicationProperties

use of org.apache.qpid.server.protocol.v1_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.server.protocol.v1_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.server.protocol.v1_0.type.messaging.ApplicationProperties in project qpid-broker-j by apache.

the class MessageConverter_1_0_to_v0_10Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, final DeliveryAnnotations deliveryAnnotations, final MessageAnnotations messageAnnotations, final Properties properties, final ApplicationProperties applicationProperties, final long arrivalTime, final EncodingRetainingSection section) {
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations.createEncodingRetainingSection(), messageAnnotations.createEncodingRetainingSection(), properties.createEncodingRetainingSection(), applicationProperties.createEncodingRetainingSection(), new Footer(Collections.emptyMap()).createEncodingRetainingSection(), arrivalTime, 0);
    when(storedMessage.getMetaData()).thenReturn(metaData);
    if (section != null) {
        // TODO this seems to leak QBBs
        final QpidByteBuffer combined = section.getEncodedForm();
        when(storedMessage.getContentSize()).thenReturn((int) section.getEncodedSize());
        final ArgumentCaptor<Integer> offsetCaptor = ArgumentCaptor.forClass(Integer.class);
        final ArgumentCaptor<Integer> sizeCaptor = ArgumentCaptor.forClass(Integer.class);
        when(storedMessage.getContent(offsetCaptor.capture(), sizeCaptor.capture())).then(invocation -> combined.view(offsetCaptor.getValue(), sizeCaptor.getValue()));
    } else {
        when(storedMessage.getContent(0, 0)).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    }
    return new Message_1_0(storedMessage);
}
Also used : Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) MessageMetaData_1_0(org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0) QpidByteBuffer(org.apache.qpid.server.bytebuffer.QpidByteBuffer)

Example 4 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testCreationTimeConversion.

@Test
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, null);
    final MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final DeliveryProperties deliveryProperties = convertedMessage.getStoredMessage().getMetaData().getDeliveryProperties();
    assertEquals("Unexpected timestamp", timestamp, deliveryProperties.getTimestamp());
}
Also used : Header(org.apache.qpid.server.protocol.v1_0.type.messaging.Header) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) 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) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) DeliveryProperties(org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) Date(java.util.Date) Test(org.junit.Test)

Example 5 with ApplicationProperties

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

the class PropertyConverter_1_0_to_0_10Test method testApplicationPropertiesConversion.

@Test
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 MessageTransferMessage convertedMessage = _messageConverter.convert(message, _namedAddressSpace);
    final MessageProperties messageProperties = convertedMessage.getStoredMessage().getMetaData().getMessageProperties();
    final Map<String, Object> headers = messageProperties.getApplicationHeaders();
    assertEquals("Unexpected headers", properties, new HashMap<>(headers));
}
Also used : HashMap(java.util.HashMap) MessageTransferMessage(org.apache.qpid.server.protocol.v0_10.MessageTransferMessage) MessageProperties(org.apache.qpid.server.protocol.v0_10.transport.MessageProperties) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Message_1_0(org.apache.qpid.server.protocol.v1_0.Message_1_0) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) Test(org.junit.Test)

Aggregations

Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)31 Test (org.junit.Test)29 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)24 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)23 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)16 HashMap (java.util.HashMap)15 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)15 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)14 MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)14 Header (org.apache.qpid.server.protocol.v1_0.type.messaging.Header)13 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)11 DeliveryAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations)11 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)10 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)10 QpidByteBuffer (org.apache.qpid.server.bytebuffer.QpidByteBuffer)9 Date (java.util.Date)8 Footer (org.apache.qpid.server.protocol.v1_0.type.messaging.Footer)8 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)7 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)5