Search in sources :

Example 6 with AMQPMessage

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

the class AMQPMessageTest method testIsDurableFromMessage.

@Test
public void testIsDurableFromMessage() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    protonMessage.setDurable(true);
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertTrue(decoded.isDurable());
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 7 with AMQPMessage

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

the class AMQPMessageTest method testExtraProperty.

@Test
public void testExtraProperty() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    byte[] original = RandomUtil.randomBytes();
    SimpleString name = SimpleString.toSimpleString("myProperty");
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    decoded.setAddress("someAddress");
    decoded.setMessageID(33);
    decoded.putExtraBytesProperty(name, original);
    ICoreMessage coreMessage = decoded.toCore();
    Assert.assertEquals(original, coreMessage.getBytesProperty(name));
    ActiveMQBuffer buffer = ActiveMQBuffers.pooledBuffer(10 * 1024);
    try {
        decoded.getPersister().encode(buffer, decoded);
        // the journal reader will read 1 byte to find the persister
        Assert.assertEquals(AMQPMessagePersisterV2.getInstance().getID(), buffer.readByte());
        AMQPMessage readMessage = (AMQPMessage) decoded.getPersister().decode(buffer, null);
        Assert.assertEquals(33, readMessage.getMessageID());
        Assert.assertEquals("someAddress", readMessage.getAddress());
        Assert.assertArrayEquals(original, readMessage.getExtraBytesProperty(name));
    } finally {
        buffer.release();
    }
    {
        ICoreMessage embeddedMessage = EmbedMessageUtil.embedAsCoreMessage(decoded);
        AMQPMessage readMessage = (AMQPMessage) EmbedMessageUtil.extractEmbedded(embeddedMessage);
        Assert.assertEquals(33, readMessage.getMessageID());
        Assert.assertEquals("someAddress", readMessage.getAddress());
        Assert.assertArrayEquals(original, readMessage.getExtraBytesProperty(name));
    }
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) 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) ActiveMQBuffer(org.apache.activemq.artemis.api.core.ActiveMQBuffer) Test(org.junit.Test)

Example 8 with AMQPMessage

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

the class AMQPMessageTest method encodeAndDecodeMessage.

private AMQPMessage encodeAndDecodeMessage(MessageImpl message) {
    ByteBuf nettyBuffer = Unpooled.buffer(1500);
    message.encode(new NettyWritable(nettyBuffer));
    byte[] bytes = new byte[nettyBuffer.writerIndex()];
    nettyBuffer.readBytes(bytes);
    return new AMQPMessage(0, bytes);
}
Also used : ByteBuf(io.netty.buffer.ByteBuf) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) NettyWritable(org.apache.activemq.artemis.protocol.amqp.util.NettyWritable)

Example 9 with AMQPMessage

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

the class AMQPMessageTest method testGetTimestampFromMessageWithNoCreateTimeSet.

@Test
public void testGetTimestampFromMessageWithNoCreateTimeSet() {
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(0L, decoded.getTimestamp());
}
Also used : Header(org.apache.qpid.proton.amqp.messaging.Header) MessageImpl(org.apache.qpid.proton.message.impl.MessageImpl) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 10 with AMQPMessage

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

the class AMQPMessageTest method testGetGroupIDFromMessage.

@Test
public void testGetGroupIDFromMessage() {
    final String GROUP_ID = "group-1";
    MessageImpl protonMessage = (MessageImpl) Message.Factory.create();
    protonMessage.setHeader(new Header());
    protonMessage.setGroupId(GROUP_ID);
    AMQPMessage decoded = encodeAndDecodeMessage(protonMessage);
    assertEquals(GROUP_ID, decoded.getGroupID().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)

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