Search in sources :

Example 36 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class AMQPMessageTest method testGetAddressFromMessage.

@Test
public void testGetAddressFromMessage() {
    final String ADDRESS = "myQueue";
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    protonMessage.setAddress(ADDRESS);
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(ADDRESS, decoded.getAddress());
}
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 37 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class AMQPMessageTest method testGetTimestampFromMessage.

@Test
public void testGetTimestampFromMessage() {
    Date timestamp = new Date(System.currentTimeMillis());
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    Properties properties = new Properties();
    properties.setCreationTime(timestamp);
    protonMessage.setProperties(properties);
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(timestamp.getTime(), decoded.getTimestamp());
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) Properties(org.apache.qpid.proton.amqp.messaging.Properties) ApplicationProperties(org.apache.qpid.proton.amqp.messaging.ApplicationProperties) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Date(java.util.Date) Test(org.junit.Test)

Example 38 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage 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 39 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage in project activemq-artemis by apache.

the class AMQPMessageTest method testGetPriorityFromMessageWithNoPrioritySet.

@Test
public void testGetPriorityFromMessageWithNoPrioritySet() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(AMQPMessage.DEFAULT_MESSAGE_PRIORITY, decoded.getPriority());
}
Also used : MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 40 with AMQPMessage

use of org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage 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)

Aggregations

AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)57 Test (org.junit.Test)49 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)35 Message (org.apache.qpid.proton.message.Message)26 MessageImpl (org.apache.qpid.proton.message.impl.MessageImpl)21 ServerJMSBytesMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage)20 ServerJMSMapMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage)20 ServerJMSMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage)20 ServerJMSStreamMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage)20 ServerJMSTextMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage)20 TextMessage (javax.jms.TextMessage)19 ServerJMSObjectMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage)19 AmqpValue (org.apache.qpid.proton.amqp.messaging.AmqpValue)19 Header (org.apache.qpid.proton.amqp.messaging.Header)11 ApplicationProperties (org.apache.qpid.proton.amqp.messaging.ApplicationProperties)10 HashMap (java.util.HashMap)9 Binary (org.apache.qpid.proton.amqp.Binary)9 Data (org.apache.qpid.proton.amqp.messaging.Data)6 SimpleString (org.apache.activemq.artemis.api.core.SimpleString)5 ByteBuf (io.netty.buffer.ByteBuf)4