org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations Java Examples

The following examples show how to use org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSendBufferAddsDeliveryCountOnlyToSendMessageAndTrimsDeliveryAnnotations() {
   MessageImpl protonMessage = createProtonMessage();
   DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   deliveryAnnotations.getValue().put(Symbol.valueOf("testGetSendBufferRemoveDeliveryAnnotations"), "X");
   protonMessage.setDeliveryAnnotations(deliveryAnnotations);
   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);

   ReadableBuffer buffer = message.getSendBuffer(7);
   assertNotNull(buffer);
   message.reencode(); // Ensures Header is current if accidentally updated

   AMQPStandardMessage copy = new AMQPStandardMessage(0, buffer, null, null);

   MessageImpl originalsProtonMessage = message.getProtonMessage();
   MessageImpl copyProtonMessage = copy.getProtonMessage();
   assertProtonMessageNotEquals(originalsProtonMessage, copyProtonMessage);

   assertNull(originalsProtonMessage.getHeader().getDeliveryCount());
   assertEquals(6, copyProtonMessage.getHeader().getDeliveryCount().intValue());
   assertNull(copyProtonMessage.getDeliveryAnnotations());
}
 
Example #2
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetSendBufferRemoveDeliveryAnnotations() {
   MessageImpl protonMessage = createProtonMessage();
   DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   deliveryAnnotations.getValue().put(Symbol.valueOf("testGetSendBufferRemoveDeliveryAnnotations"), "X");
   protonMessage.setDeliveryAnnotations(deliveryAnnotations);
   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);

   ReadableBuffer buffer = message.getSendBuffer(1);
   assertNotNull(buffer);

   AMQPStandardMessage copy = new AMQPStandardMessage(0, buffer, null, null);

   MessageImpl copyProtonMessage = copy.getProtonMessage();
   assertProtonMessageNotEquals(message.getProtonMessage(), copyProtonMessage);
   assertNull(copyProtonMessage.getDeliveryAnnotations());
}
 
Example #3
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 6 votes vote down vote up
@Override
public void write(DeliveryAnnotations val) {
    WritableBuffer buffer = getEncoder().getBuffer();

    buffer.put(EncodingCodes.DESCRIBED_TYPE_INDICATOR);
    buffer.put(EncodingCodes.SMALLULONG);
    buffer.put(DESCRIPTOR_CODE);

    MapType mapType = (MapType) getEncoder().getType(val.getValue());

    mapType.setKeyEncoding(symbolType);
    try {
        mapType.write(val.getValue());
    } finally {
        mapType.setKeyEncoding(null);
    }
}
 
Example #4
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetDeliveryAnnotations() {
   MessageImpl protonMessage = createProtonMessage();
   DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   deliveryAnnotations.getValue().put(Symbol.valueOf(UUID.randomUUID().toString()), "test-1");
   protonMessage.setDeliveryAnnotations(deliveryAnnotations);

   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);

   DeliveryAnnotations decoded = message.getDeliveryAnnotations();
   assertNotSame(decoded, protonMessage.getDeliveryAnnotations());
   assertDeliveryAnnotationsEquals(protonMessage.getDeliveryAnnotations(), decoded);

   // Update the values
   decoded.getValue().put(Symbol.valueOf(UUID.randomUUID().toString()), "test-2");

   // Check that the message is unaffected.
   assertDeliveryAnnotationsNotEquals(protonMessage.getDeliveryAnnotations(), decoded);
}
 
Example #5
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testDeliveryAnnotationsReturnedOnNonEmptyDeliveryAnnotationsMap() throws Exception {
    AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();

    Map<Symbol, Object> deliveryAnnotationsMap = new HashMap<>();
    deliveryAnnotationsMap.put(Symbol.valueOf("test"), "value");
    amqpMessageFacade.setDeliveryAnnotations(new DeliveryAnnotations(deliveryAnnotationsMap));

    assertNotNull(amqpMessageFacade.getDeliveryAnnotations());
}
 
Example #6
Source File: Proton.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
public static Message message(Header header,
                  DeliveryAnnotations deliveryAnnotations, MessageAnnotations messageAnnotations,
                  Properties properties, ApplicationProperties applicationProperties,
                  Section body, Footer footer)
{
    return Message.Factory.create(header, deliveryAnnotations,
                                  messageAnnotations, properties,
                                  applicationProperties, body, footer);
}
 
Example #7
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
private boolean isEquals(DeliveryAnnotations left, DeliveryAnnotations right) {
   if (left == null && right == null) {
      return true;
   }
   if (!isNullnessEquals(left, right)) {
      return false;
   }

   return isEquals(left.getValue(), right.getValue());
}
 
Example #8
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetSendBufferWithoutDeliveryAnnotations() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   Header header = new Header();
   header.setDeliveryCount(new UnsignedInteger(1));
   protonMessage.setHeader(header);
   Properties properties = new Properties();
   properties.setTo("someNiceLocal");
   protonMessage.setProperties(properties);
   protonMessage.setBody(new AmqpValue("Sample payload"));

   DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   final String annotationKey = "annotationKey";
   final String annotationValue = "annotationValue";
   deliveryAnnotations.getValue().put(Symbol.getSymbol(annotationKey), annotationValue);
   protonMessage.setDeliveryAnnotations(deliveryAnnotations);

   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   ReadableBuffer sendBuffer = decoded.getSendBuffer(1);
   assertEquals(decoded.getEncodeSize(), sendBuffer.capacity());
   AMQPStandardMessage msgFromSendBuffer = new AMQPStandardMessage(0, sendBuffer, null, null);
   assertEquals("someNiceLocal", msgFromSendBuffer.getAddress());
   assertNull(msgFromSendBuffer.getDeliveryAnnotations());

   // again with higher deliveryCount
   ReadableBuffer sendBuffer2 = decoded.getSendBuffer(5);
   assertEquals(decoded.getEncodeSize(), sendBuffer2.capacity());
   AMQPStandardMessage msgFromSendBuffer2 = new AMQPStandardMessage(0, sendBuffer2, null, null);
   assertEquals("someNiceLocal", msgFromSendBuffer2.getAddress());
   assertNull(msgFromSendBuffer2.getDeliveryAnnotations());
}
 
Example #9
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 5 votes vote down vote up
@Test
public void testCopyMessageDoesNotRemovesMessageAnnotations() {
   MessageImpl protonMessage = createProtonMessage();
   DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   deliveryAnnotations.getValue().put(Symbol.valueOf("testCopyMessageRemovesMessageAnnotations"), "1");
   protonMessage.setDeliveryAnnotations(deliveryAnnotations);

   AMQPStandardMessage message = new AMQPStandardMessage(0, encodeMessage(protonMessage), null, null);
   message.setMessageID(127);
   AMQPStandardMessage copy = (AMQPStandardMessage) message.copy();

   assertEquals(message.getMessageID(), copy.getMessageID());
   assertProtonMessageEquals(message.getProtonMessage(), copy.getProtonMessage());
   assertNotNull(copy.getDeliveryAnnotations());
}
 
Example #10
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 5 votes vote down vote up
@Test
public void testNoDeliveryAnnotationsReturnedOnEmptyDeliveryAnnotationsMap() throws Exception {
    AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();

    Map<Symbol, Object> deliveryAnnotationsMap = new HashMap<>();
    amqpMessageFacade.setDeliveryAnnotations(new DeliveryAnnotations(deliveryAnnotationsMap));

    assertNull(amqpMessageFacade.getDeliveryAnnotations());
}
 
Example #11
Source File: Message.java    From qpid-proton-j with Apache License 2.0 5 votes vote down vote up
public static Message create(Header header,
                             DeliveryAnnotations deliveryAnnotations,
                             MessageAnnotations messageAnnotations,
                             Properties properties,
                             ApplicationProperties applicationProperties,
                             Section body,
                             Footer footer) {
    return new MessageImpl(header, deliveryAnnotations,
                           messageAnnotations, properties,
                           applicationProperties, body, footer);
}
 
Example #12
Source File: AmqpCodec.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
/**
 * Given a Message instance, encode the Message to the wire level representation
 * of that Message.
 *
 * @param message
 *      the Message that is to be encoded into the wire level representation.
 *
 * @return a buffer containing the wire level representation of the input Message.
 */
public static ByteBuf encodeMessage(AmqpJmsMessageFacade message) {
    EncoderDecoderContext context = TLS_CODEC.get();

    AmqpWritableBuffer buffer = new AmqpWritableBuffer();

    EncoderImpl encoder = context.encoder;
    encoder.setByteBuffer(buffer);

    Header header = message.getHeader();
    DeliveryAnnotations deliveryAnnotations = message.getDeliveryAnnotations();
    MessageAnnotations messageAnnotations = message.getMessageAnnotations();
    Properties properties = message.getProperties();
    ApplicationProperties applicationProperties = message.getApplicationProperties();
    Section body = message.getBody();
    Footer footer = message.getFooter();

    if (header != null) {
        encoder.writeObject(header);
    }
    if (deliveryAnnotations != null) {
        encoder.writeObject(deliveryAnnotations);
    }
    if (messageAnnotations != null) {
        // Ensure annotations contain required message type and destination type data
        AmqpDestinationHelper.setReplyToAnnotationFromDestination(message.getReplyTo(), messageAnnotations);
        AmqpDestinationHelper.setToAnnotationFromDestination(message.getDestination(), messageAnnotations);
        messageAnnotations.getValue().put(AmqpMessageSupport.JMS_MSG_TYPE, message.getJmsMsgType());
        encoder.writeObject(messageAnnotations);
    } else {
        buffer.put(getCachedMessageAnnotationsBuffer(message, context));
    }
    if (properties != null) {
        encoder.writeObject(properties);
    }
    if (applicationProperties != null) {
        encoder.writeObject(applicationProperties);
    }
    if (body != null) {
        encoder.writeObject(body);
    }
    if (footer != null) {
        encoder.writeObject(footer);
    }

    encoder.setByteBuffer((WritableBuffer) null);

    return buffer.getBuffer();
}
 
Example #13
Source File: AmqpJmsMessageFacade.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
void setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations) {
    if (deliveryAnnotations != null) {
        this.deliveryAnnotationsMap = deliveryAnnotations.getValue();
    }
}
 
Example #14
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private void assertDeliveryAnnotationsNotEquals(DeliveryAnnotations left, DeliveryAnnotations right) {
   if (isEquals(left, right)) {
      fail("DeliveryAnnotations values should not be equal: left{" + left + "} right{" + right + "}");
   }
}
 
Example #15
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private void assertDeliveryAnnotationsEquals(DeliveryAnnotations left, DeliveryAnnotations right) {
   if (!isEquals(left, right)) {
      fail("DeliveryAnnotations values should be equal: left{" + left + "} right{" + right + "}");
   }
}
 
Example #16
Source File: AMQPMessageTest.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetSendBufferWithDeliveryAnnotations() {
   MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
   Header header = new Header();
   header.setDeliveryCount(new UnsignedInteger(1));
   protonMessage.setHeader(header);
   Properties properties = new Properties();
   properties.setTo("someNiceLocal");
   protonMessage.setProperties(properties);
   protonMessage.setBody(new AmqpValue("Sample payload"));

   AMQPStandardMessage decoded = encodeAndDecodeMessage(protonMessage);

   DeliveryAnnotations newDeliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
   final String annotationKey = "annotationKey";
   final String annotationValue = "annotationValue";
   newDeliveryAnnotations.getValue().put(Symbol.getSymbol(annotationKey), annotationValue);
   decoded.setDeliveryAnnotationsForSendBuffer(newDeliveryAnnotations);

   ReadableBuffer sendBuffer = decoded.getSendBuffer(1);
   assertEquals(decoded.getEncodeSize(), sendBuffer.capacity());
   AMQPStandardMessage msgFromSendBuffer = new AMQPStandardMessage(0, sendBuffer, null, null);
   assertEquals("someNiceLocal", msgFromSendBuffer.getAddress());
   assertNotNull(msgFromSendBuffer.getDeliveryAnnotations());
   assertEquals(1, msgFromSendBuffer.getDeliveryAnnotations().getValue().size());
   assertEquals(annotationValue, msgFromSendBuffer.getDeliveryAnnotations().getValue().get(Symbol.getSymbol(annotationKey)));

   // again with higher deliveryCount
   DeliveryAnnotations newDeliveryAnnotations2 = new DeliveryAnnotations(new HashMap<>());
   final String annotationKey2 = "annotationKey2";
   final String annotationValue2 = "annotationValue2";
   newDeliveryAnnotations2.getValue().put(Symbol.getSymbol(annotationKey2), annotationValue2);
   decoded.setDeliveryAnnotationsForSendBuffer(newDeliveryAnnotations2);

   ReadableBuffer sendBuffer2 = decoded.getSendBuffer(5);
   assertEquals(decoded.getEncodeSize(), sendBuffer2.capacity());
   AMQPStandardMessage msgFromSendBuffer2 = new AMQPStandardMessage(0, sendBuffer2, null, null);
   assertEquals("someNiceLocal", msgFromSendBuffer2.getAddress());
   assertNotNull(msgFromSendBuffer2.getDeliveryAnnotations());
   assertEquals(1, msgFromSendBuffer2.getDeliveryAnnotations().getValue().size());
   assertEquals(annotationValue2, msgFromSendBuffer2.getDeliveryAnnotations().getValue().get(Symbol.getSymbol(annotationKey2)));
}
 
Example #17
Source File: AMQPMessage.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
protected synchronized void scanMessageData() {
   this.messageDataScanned = MessageDataScanningStatus.SCANNED.code;
   DecoderImpl decoder = TLSEncode.getDecoder();
   decoder.setBuffer(getData().rewind());

   resetMessageData();

   ReadableBuffer data = getData();

   try {
      while (data.hasRemaining()) {
         int constructorPos = data.position();
         TypeConstructor<?> constructor = decoder.readConstructor();
         if (Header.class.equals(constructor.getTypeClass())) {
            header = (Header) constructor.readValue();
            headerPosition = constructorPos;
            encodedHeaderSize = data.position();
            if (header.getTtl() != null) {
               expiration = System.currentTimeMillis() + header.getTtl().intValue();
            }
         } else if (DeliveryAnnotations.class.equals(constructor.getTypeClass())) {
            // Don't decode these as they are not used by the broker at all and are
            // discarded on send, mark for lazy decode if ever needed.
            constructor.skipValue();
            deliveryAnnotationsPosition = constructorPos;
            encodedDeliveryAnnotationsSize = data.position() - constructorPos;
         } else if (MessageAnnotations.class.equals(constructor.getTypeClass())) {
            messageAnnotationsPosition = constructorPos;
            messageAnnotations = (MessageAnnotations) constructor.readValue();
         } else if (Properties.class.equals(constructor.getTypeClass())) {
            propertiesPosition = constructorPos;
            properties = (Properties) constructor.readValue();

            if (properties.getAbsoluteExpiryTime() != null && properties.getAbsoluteExpiryTime().getTime() > 0) {
               expiration = properties.getAbsoluteExpiryTime().getTime();
            }
         } else if (ApplicationProperties.class.equals(constructor.getTypeClass())) {
            // Lazy decoding will start at the TypeConstructor of these ApplicationProperties
            // but we scan past it to grab the location of the possible body and footer section.
            applicationPropertiesPosition = constructorPos;
            constructor.skipValue();
            remainingBodyPosition = data.hasRemaining() ? data.position() : VALUE_NOT_PRESENT;
            break;
         } else {
            // This will be either the body or a Footer section which will be treated as an immutable
            // and be copied as is when re-encoding the message.
            remainingBodyPosition = constructorPos;
            break;
         }
      }
   } finally {
      decoder.setByteBuffer(null);
      data.rewind();
   }
}
 
Example #18
Source File: AmqpMessage.java    From activemq-artemis with Apache License 2.0 4 votes vote down vote up
private void lazyCreateDeliveryAnnotations() {
   if (deliveryAnnotationsMap == null) {
      deliveryAnnotationsMap = new HashMap<>();
      message.setDeliveryAnnotations(new DeliveryAnnotations(deliveryAnnotationsMap));
   }
}
 
Example #19
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public DeliveryAnnotations readValue() {
    DecoderImpl decoder = getDecoder();
    ReadableBuffer buffer = decoder.getBuffer();

    final int size;
    final int count;

    byte encodingCode = buffer.get();

    switch (encodingCode) {
        case EncodingCodes.MAP8:
            size = buffer.get() & 0xFF;
            count = buffer.get() & 0xFF;
            break;
        case EncodingCodes.MAP32:
            size = buffer.getInt();
            count = buffer.getInt();
            break;
        case EncodingCodes.NULL:
            return new DeliveryAnnotations(null);
        default:
            throw new ProtonException("Expected Map type but found encoding: " + encodingCode);
    }

    if (count > buffer.remaining()) {
        throw new IllegalArgumentException("Map element count " + count + " is specified to be greater than the " +
                                           "amount of data available (" + buffer.remaining() + ")");
    }

    TypeConstructor<?> valueConstructor = null;

    Map<Symbol, Object> map = new LinkedHashMap<>(count);
    for(int i = 0; i < count / 2; i++) {
        Symbol key = decoder.readSymbol(null);
        if (key == null) {
            throw new DecodeException("String key in DeliveryAnnotations cannot be null");
        }

        boolean arrayType = false;
        byte code = buffer.get(buffer.position());
        switch (code)
        {
            case EncodingCodes.ARRAY8:
            case EncodingCodes.ARRAY32:
                arrayType = true;
        }

        valueConstructor = findNextDecoder(decoder, buffer, valueConstructor);

        final Object value;

        if (arrayType) {
            value = ((ArrayType.ArrayEncoding) valueConstructor).readValueArray();
        } else {
            value = valueConstructor.readValue();
        }

        map.put(key, value);
    }

    return new DeliveryAnnotations(map);
}
 
Example #20
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public Collection<? extends TypeEncoding<DeliveryAnnotations>> getAllEncodings() {
    return annotationsType.getAllEncodings();
}
 
Example #21
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public TypeEncoding<DeliveryAnnotations> getCanonicalEncoding() {
    return annotationsType.getCanonicalEncoding();
}
 
Example #22
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public TypeEncoding<DeliveryAnnotations> getEncoding(DeliveryAnnotations val) {
    return annotationsType.getEncoding(val);
}
 
Example #23
Source File: FastPathDeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
public Class<DeliveryAnnotations> getTypeClass() {
    return DeliveryAnnotations.class;
}
 
Example #24
Source File: DeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public Class<DeliveryAnnotations> getTypeClass()
{
    return DeliveryAnnotations.class;
}
 
Example #25
Source File: DeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
public DeliveryAnnotations newInstance(Object described)
{
    return new DeliveryAnnotations( (Map) described );
}
 
Example #26
Source File: DeliveryAnnotationsType.java    From qpid-proton-j with Apache License 2.0 4 votes vote down vote up
@Override
protected Map wrap(DeliveryAnnotations val)
{
    return val.getValue();
}
 
Example #27
Source File: AmqpJmsMessageFacadeTest.java    From qpid-jms with Apache License 2.0 4 votes vote down vote up
@Test
public void testBasicMessageCopy() throws JMSException {
    AmqpJmsMessageFacade source = createNewMessageFacade();

    Map<Symbol, Object> deliveryAnnotationsMap = new HashMap<>();
    deliveryAnnotationsMap.put(Symbol.valueOf("test-annotation"), "value");
    source.setDeliveryAnnotations(new DeliveryAnnotations(deliveryAnnotationsMap));

    Map<Symbol, Object> footerMap = new HashMap<>();
    footerMap.put(Symbol.valueOf("test-footer"), "value");
    source.setFooter(new Footer(footerMap));

    JmsQueue aQueue = new JmsQueue("Test-Queue");
    JmsTemporaryQueue tempQueue = new JmsTemporaryQueue("Test-Temp-Queue");

    source.setDestination(aQueue);
    source.setReplyTo(tempQueue);

    source.setContentType(Symbol.valueOf("Test-ContentType"));
    source.setCorrelationId("MY-APP-ID");
    source.setExpiration(42L);
    source.setGroupId("TEST-GROUP");
    source.setGroupSequence(23);
    source.setMessageId("ID:TEST-MESSAGEID");
    source.setPriority((byte) 1);
    source.setPersistent(false);
    source.setRedeliveryCount(12);
    source.setTimestamp(150L);
    source.setUserId("Cookie-Monster");
    source.setDeliveryTime(123456, false);

    source.setProperty("APP-Prop-1", "APP-Prop-1-Value");
    source.setProperty("APP-Prop-2", "APP-Prop-2-Value");

    source.setTracingContext("Tracing-Key", "Tracing-Detail");

    // ------------------------------------

    AmqpJmsMessageFacade copy = source.copy();

    assertSame(source.getConnection(), copy.getConnection());
    assertEquals(source.hasBody(), copy.hasBody());

    assertEquals(source.getDestination(), copy.getDestination());
    assertEquals(source.getReplyTo(), copy.getReplyTo());

    assertEquals(source.getContentType(), copy.getContentType());
    assertEquals(source.getCorrelationId(), copy.getCorrelationId());
    assertEquals(source.getExpiration(), copy.getExpiration());
    assertEquals(source.getGroupId(), copy.getGroupId());
    assertEquals(source.getGroupSequence(), copy.getGroupSequence());
    assertEquals(source.getMessageId(), copy.getMessageId());
    assertEquals(source.getPriority(), copy.getPriority());
    assertEquals(source.isPersistent(), copy.isPersistent());
    assertEquals(source.getRedeliveryCount(), copy.getRedeliveryCount());
    assertEquals(source.getTimestamp(), copy.getTimestamp());
    assertEquals(source.getUserId(), copy.getUserId());
    assertEquals(source.getDeliveryTime(), copy.getDeliveryTime());

    // There should be two since none of the extended options were set
    assertEquals(2, copy.getPropertyNames().size());

    assertNotNull(copy.getProperty("APP-Prop-1"));
    assertNotNull(copy.getProperty("APP-Prop-2"));

    assertEquals("APP-Prop-1-Value", copy.getProperty("APP-Prop-1"));
    assertEquals("APP-Prop-2-Value", copy.getProperty("APP-Prop-2"));

    assertEquals("Tracing-Detail", copy.getTracingContext("Tracing-Key"));

    Footer copiedFooter = copy.getFooter();
    DeliveryAnnotations copiedDeliveryAnnotations = copy.getDeliveryAnnotations();

    assertNotNull(copiedFooter);
    assertNotNull(copiedDeliveryAnnotations);

    assertNotNull(copiedFooter.getValue());
    assertNotNull(copiedDeliveryAnnotations.getValue());

    assertFalse(copiedFooter.getValue().isEmpty());
    assertFalse(copiedDeliveryAnnotations.getValue().isEmpty());

    assertTrue(copiedFooter.getValue().containsKey(Symbol.valueOf("test-footer")));
    assertTrue(copiedDeliveryAnnotations.getValue().containsKey(Symbol.valueOf("test-annotation")));
}
 
Example #28
Source File: AMQPMessage.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Sets the delivery annotations to be included when encoding the message for sending it on the wire.
 *
 * The broker can add additional message annotations as long as the annotations being added follow the
 * rules from the spec. If the user adds something that the remote doesn't understand and it is not
 * prefixed with "x-opt" the remote can just kill the link. See:
 *
 *     http://docs.oasis-open.org/amqp/core/v1.0/os/amqp-core-messaging-v1.0-os.html#type-annotations
 *
 * @param deliveryAnnotations delivery annotations used in the sendBuffer() method
 */
public final void setDeliveryAnnotationsForSendBuffer(DeliveryAnnotations deliveryAnnotations) {
   this.deliveryAnnotationsForSendBuffer = deliveryAnnotations;
}
 
Example #29
Source File: AMQPMessage.java    From activemq-artemis with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a copy of the MessageAnnotations in the message if present or null.  Changes to the
 * returned DeliveryAnnotations instance do not affect the original Message.
 *
 * @return a copy of the {@link DeliveryAnnotations} present in the message or null if non present.
 */
public final DeliveryAnnotations getDeliveryAnnotations() {
   ensureScanning();
   return scanForMessageSection(deliveryAnnotationsPosition, DeliveryAnnotations.class);
}
 
Example #30
Source File: Message.java    From qpid-proton-j with Apache License 2.0 votes vote down vote up
void setDeliveryAnnotations(DeliveryAnnotations deliveryAnnotations);