Search in sources :

Example 16 with Header

use of org.apache.qpid.proton.amqp.messaging.Header in project activemq-artemis by apache.

the class AMQPMessageTest method testVerySimple.

@Test
public void testVerySimple() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    Properties properties = new Properties();
    properties.setTo("someNiceLocal");
    protonMessage.setProperties(properties);
    protonMessage.getHeader().setDeliveryCount(new UnsignedInteger(7));
    protonMessage.getHeader().setDurable(Boolean.TRUE);
    protonMessage.setApplicationProperties(new ApplicationProperties(new HashMap()));
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(7, decoded.getHeader().getDeliveryCount().intValue());
    assertEquals(true, decoded.getHeader().getDurable());
    assertEquals("someNiceLocal", decoded.getAddress());
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) HashMap(java.util.HashMap) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) Properties(org.apache.qpid.proton.amqp.messaging.Properties) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) UnsignedInteger(org.apache.qpid.proton.amqp.UnsignedInteger) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 17 with Header

use of org.apache.qpid.proton.amqp.messaging.Header in project activemq-artemis by apache.

the class AMQPMessageTest method testApplicationPropertiesReencode.

@Test
public void testApplicationPropertiesReencode() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    Properties properties = new Properties();
    properties.setTo("someNiceLocal");
    protonMessage.setProperties(properties);
    protonMessage.getHeader().setDeliveryCount(new UnsignedInteger(7));
    protonMessage.getHeader().setDurable(Boolean.TRUE);
    HashMap map = new HashMap();
    map.put("key", "string1");
    protonMessage.setApplicationProperties(new ApplicationProperties(map));
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals("someNiceLocal", decoded.getAddress());
    decoded.setAddress("newAddress");
    decoded.reencode();
    assertEquals(7, decoded.getHeader().getDeliveryCount().intValue());
    assertEquals(true, decoded.getHeader().getDurable());
    assertEquals("newAddress", decoded.getAddress());
    assertEquals("string1", decoded.getObjectProperty("key"));
    // validate if the message will be the same after delivery
    AMQPMessage newDecoded = encodeDelivery(decoded, 3);
    assertEquals(2, decoded.getHeader().getDeliveryCount().intValue());
    assertEquals(true, newDecoded.getHeader().getDurable());
    assertEquals("newAddress", newDecoded.getAddress());
    assertEquals("string1", newDecoded.getObjectProperty("key"));
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) HashMap(java.util.HashMap) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) Properties(org.apache.qpid.proton.amqp.messaging.Properties) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) UnsignedInteger(org.apache.qpid.proton.amqp.UnsignedInteger) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 18 with Header

use of org.apache.qpid.proton.amqp.messaging.Header in project activemq-artemis by apache.

the class AMQPMessageTest method testGetAddressSimpleStringFromMessage.

@Test
public void testGetAddressSimpleStringFromMessage() {
    final String ADDRESS = "myQueue";
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    protonMessage.setAddress(ADDRESS);
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(ADDRESS, decoded.getAddressSimpleString().toString());
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 19 with Header

use of org.apache.qpid.proton.amqp.messaging.Header in project activemq-artemis by apache.

the class AMQPMessage method initalizeObjects.

private void initalizeObjects() {
    if (protonMessage == null) {
        if (data == null) {
            headerEnds = 0;
            messagePaylodStart = 0;
            _header = new Header();
            _deliveryAnnotations = new DeliveryAnnotations(new HashMap<>());
            _properties = new Properties();
            applicationProperties = new ApplicationProperties(new HashMap<>());
            protonMessage = (MessageImpl) Message.Factory.create();
            protonMessage.setApplicationProperties(applicationProperties);
            protonMessage.setDeliveryAnnotations(_deliveryAnnotations);
        }
    }
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) HashMap(java.util.HashMap) DeliveryAnnotations(org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) TypedProperties(org.apache.activemq.artemis.utils.collections.TypedProperties) Properties(org.apache.qpid.proton.amqp.messaging.Properties) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties)

Aggregations

Header (org.apache.qpid.proton.amqp.messaging.Header)19 Test (org.junit.Test)12 AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)11 MessageImpl (org.apache.qpid.proton.message.impl.MessageImpl)10 Properties (org.apache.qpid.proton.amqp.messaging.Properties)8 ApplicationProperties (org.apache.qpid.proton.amqp.messaging.ApplicationProperties)7 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 UnsignedInteger (org.apache.qpid.proton.amqp.UnsignedInteger)5 HashMap (java.util.HashMap)4 NettyWritable (org.apache.activemq.artemis.protocol.amqp.util.NettyWritable)3 TypedProperties (org.apache.activemq.artemis.utils.collections.TypedProperties)3 DeliveryAnnotations (org.apache.qpid.proton.amqp.messaging.DeliveryAnnotations)3 MessageAnnotations (org.apache.qpid.proton.amqp.messaging.MessageAnnotations)3 ByteBuf (io.netty.buffer.ByteBuf)2 URI (java.net.URI)2 Date (java.util.Date)2 Connection (javax.jms.Connection)2 Message (javax.jms.Message)2 MessageConsumer (javax.jms.MessageConsumer)2 Session (javax.jms.Session)2