Search in sources :

Example 11 with MessageAnnotations

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

the class MessageConverter_to_1_0 method createMessageAnnotation.

public static MessageAnnotations createMessageAnnotation(final EncodingRetainingSection<?> bodySection, final String contentMimeType) {
    MessageAnnotations messageAnnotations = null;
    final Symbol key = Symbol.valueOf("x-opt-jms-msg-type");
    if (contentMimeType != null) {
        if (TEXT_CONTENT_TYPES.matcher(contentMimeType).matches()) {
            messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, TEXT_MESSAGE.getType()));
        } else if (BYTES_MESSAGE_CONTENT_TYPES.matcher(contentMimeType).matches()) {
            messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, BYTES_MESSAGE.getType()));
        } else if (MAP_MESSAGE_CONTENT_TYPES.matcher(contentMimeType).matches()) {
            if (isSectionValidForJmsMap(bodySection)) {
                messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, MAP_MESSAGE.getType()));
            }
        } else if (LIST_MESSAGE_CONTENT_TYPES.matcher(contentMimeType).matches()) {
            if (isSectionValidForJmsList(bodySection)) {
                messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, STREAM_MESSAGE.getType()));
            }
        } else if (OBJECT_MESSAGE_CONTENT_TYPES.matcher(contentMimeType).matches()) {
            messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, OBJECT_MESSAGE.getType()));
        }
    } else if (bodySection instanceof AmqpValueSection && bodySection.getValue() == null) {
        messageAnnotations = new MessageAnnotations(Collections.singletonMap(key, MESSAGE.getType()));
    }
    return messageAnnotations;
}
Also used : MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) Symbol(org.apache.qpid.server.protocol.v1_0.type.Symbol) AmqpValueSection(org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValueSection)

Example 12 with MessageAnnotations

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

the class ConsumerTarget_1_0Test method createTestMessage.

private Message_1_0 createTestMessage(final Header header, long arrivalTime) {
    DeliveryAnnotationsSection deliveryAnnotations = new DeliveryAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
    MessageAnnotationsSection messageAnnotations = new MessageAnnotations(Collections.emptyMap()).createEncodingRetainingSection();
    ApplicationPropertiesSection applicationProperties = new ApplicationProperties(Collections.emptyMap()).createEncodingRetainingSection();
    FooterSection footer = new Footer(Collections.emptyMap()).createEncodingRetainingSection();
    MessageMetaData_1_0 metaData = new MessageMetaData_1_0(header.createEncodingRetainingSection(), deliveryAnnotations, messageAnnotations, new Properties().createEncodingRetainingSection(), applicationProperties, footer, arrivalTime, 0);
    final StoredMessage<MessageMetaData_1_0> storedMessage = mock(StoredMessage.class);
    when(storedMessage.getContent(eq(0), anyInt())).thenReturn(QpidByteBuffer.emptyQpidByteBuffer());
    when(storedMessage.getMetaData()).thenReturn(metaData);
    return new Message_1_0(storedMessage);
}
Also used : DeliveryAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotationsSection) FooterSection(org.apache.qpid.server.protocol.v1_0.type.messaging.FooterSection) MessageAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations) DeliveryAnnotations(org.apache.qpid.server.protocol.v1_0.type.messaging.DeliveryAnnotations) Footer(org.apache.qpid.server.protocol.v1_0.type.messaging.Footer) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) MessageAnnotationsSection(org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotationsSection) ApplicationPropertiesSection(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationPropertiesSection) ApplicationProperties(org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties) Properties(org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)

Example 13 with MessageAnnotations

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

the class EventHubReceiverImpl method createMessageId.

private MessageId createMessageId(Message message) {
    String offset = null;
    long sequenceNumber = 0;
    for (Section section : message.getPayload()) {
        if (section instanceof MessageAnnotations) {
            MessageAnnotations annotations = (MessageAnnotations) section;
            HashMap annonationMap = (HashMap) annotations.getValue();
            if (annonationMap.containsKey(OffsetKey)) {
                offset = (String) annonationMap.get(OffsetKey);
            }
            if (annonationMap.containsKey(SequenceNumberKey)) {
                sequenceNumber = (Long) annonationMap.get(SequenceNumberKey);
            }
        }
    }
    return MessageId.create(partitionId, offset, sequenceNumber);
}
Also used : HashMap(java.util.HashMap) MessageAnnotations(org.apache.qpid.amqp_1_0.type.messaging.MessageAnnotations) Section(org.apache.qpid.amqp_1_0.type.Section)

Example 14 with MessageAnnotations

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

the class PropertyConverter_1_0_to_0_8Test method testConversionOfAbsoluteExpiryTimeTakesPrecedenceOverTTL.

public void testConversionOfAbsoluteExpiryTimeTakesPrecedenceOverTTL() {
    long ttl = 10000;
    final long time = System.currentTimeMillis();
    long absoluteExpiryTime = time + ttl;
    long arrivalTime = time + 1;
    Header header = new Header();
    header.setTtl(UnsignedInteger.valueOf(ttl));
    Properties properties = new Properties();
    properties.setAbsoluteExpiryTime(new Date(absoluteExpiryTime));
    Message_1_0 message = createTestMessage(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 expiration", absoluteExpiryTime, convertedProperties.getExpiration());
}
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)

Example 15 with MessageAnnotations

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

the class MessageConverter_v1_0_to_InternalTest method testNoBodyWithUnknownMessageAnnotation.

public void testNoBodyWithUnknownMessageAnnotation() throws Exception {
    Message_1_0 sourceMessage = createTestMessage(new MessageAnnotations(Collections.singletonMap(Symbol.valueOf("x-opt-jms-msg-type"), (byte) 11)), null);
    final InternalMessage convertedMessage = _converter.convert(sourceMessage, mock(NamedAddressSpace.class));
    assertEquals("Unexpected mime type", null, convertedMessage.getMessageHeader().getMimeType());
    assertEquals("Unexpected content", null, 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)

Aggregations

MessageAnnotations (org.apache.qpid.server.protocol.v1_0.type.messaging.MessageAnnotations)22 ApplicationProperties (org.apache.qpid.server.protocol.v1_0.type.messaging.ApplicationProperties)14 Properties (org.apache.qpid.server.protocol.v1_0.type.messaging.Properties)14 Message_1_0 (org.apache.qpid.server.protocol.v1_0.Message_1_0)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 MessageTransferMessage (org.apache.qpid.server.protocol.v0_10.MessageTransferMessage)9 DeliveryProperties (org.apache.qpid.server.protocol.v0_10.transport.DeliveryProperties)8 MessageProperties (org.apache.qpid.server.protocol.v0_10.transport.MessageProperties)8 Date (java.util.Date)7 NamedAddressSpace (org.apache.qpid.server.model.NamedAddressSpace)7 AMQMessage (org.apache.qpid.server.protocol.v0_8.AMQMessage)4 Symbol (org.apache.qpid.server.protocol.v1_0.type.Symbol)4 Matchers.anyString (org.mockito.Matchers.anyString)4 InternalMessage (org.apache.qpid.server.message.internal.InternalMessage)3 MessageConversionException (org.apache.qpid.server.protocol.converter.MessageConversionException)3 BasicContentHeaderProperties (org.apache.qpid.server.protocol.v0_8.transport.BasicContentHeaderProperties)3 Binary (org.apache.qpid.server.protocol.v1_0.type.Binary)3 AmqpValue (org.apache.qpid.server.protocol.v1_0.type.messaging.AmqpValue)3 MessageMetaData_1_0 (org.apache.qpid.server.protocol.v1_0.MessageMetaData_1_0)2