Search in sources :

Example 26 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateAmqpStreamMessageFromAmqpValueWithList.

/**
 * Test that an amqp-value body containing a list results in an StreamMessage when not
 * otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateAmqpStreamMessageFromAmqpValueWithList() throws Exception {
    Message message = Proton.message();
    List<String> list = new ArrayList<>();
    message.setBody(new AmqpValue(list));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSStreamMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ArrayList(java.util.ArrayList) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 27 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateAmqpMapMessageFromAmqpValueWithMap.

/**
 * Test that an amqp-value body containing a map results in an MapMessage when not otherwise
 * annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateAmqpMapMessageFromAmqpValueWithMap() throws Exception {
    Message message = Proton.message();
    Map<String, String> map = new HashMap<>();
    message.setBody(new AmqpValue(map));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSMapMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) HashMap(java.util.HashMap) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 28 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateObjectMessageFromDataWithContentTypeAndEmptyBinary.

/**
 * Test that receiving a data body containing nothing, but with the content type set to
 * {@value AMQPMessageSupport#SERIALIZED_JAVA_OBJECT_CONTENT_TYPE} results in an
 * ObjectMessage when not otherwise annotated to indicate the type of JMS message it is.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateObjectMessageFromDataWithContentTypeAndEmptyBinary() throws Exception {
    Message message = Proton.message();
    Binary binary = new Binary(new byte[0]);
    message.setBody(new Data(binary));
    message.setContentType(AMQPMessageSupport.SERIALIZED_JAVA_OBJECT_CONTENT_TYPE.toString());
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSObjectMessage.class, jmsMessage.getClass());
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) TextMessage(javax.jms.TextMessage) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) Data(org.apache.qpid.proton.amqp.messaging.Data) Binary(org.apache.qpid.proton.amqp.Binary) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 29 with AMQPMessage

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

the class JMSTransformationSpeedComparisonTest method testBodyOnlyMessage.

@Test
public void testBodyOnlyMessage() throws Exception {
    Message message = Proton.message();
    message.setBody(new AmqpValue("String payload for AMQP message conversion performance testing."));
    AMQPMessage encoded = new AMQPMessage(message);
    // Warm up
    for (int i = 0; i < WARM_CYCLES; ++i) {
        ICoreMessage intermediate = encoded.toCore();
        encode(AMQPConverter.getInstance().fromCore(intermediate));
    }
    long totalDuration = 0;
    long startTime = System.nanoTime();
    for (int i = 0; i < PROFILE_CYCLES; ++i) {
        ICoreMessage intermediate = encoded.toCore();
        encode(AMQPConverter.getInstance().fromCore(intermediate));
    }
    totalDuration += System.nanoTime() - startTime;
    LOG_RESULTS(totalDuration);
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Message(org.apache.qpid.proton.message.Message) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 30 with AMQPMessage

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

the class JMSTransformationSpeedComparisonTest method testTypicalQpidJMSMessageOutBoundOnly.

@Test
public void testTypicalQpidJMSMessageOutBoundOnly() throws Exception {
    AMQPMessage encoded = encode(createTypicalQpidJMSMessage());
    // Warm up
    for (int i = 0; i < WARM_CYCLES; ++i) {
        ICoreMessage intermediate = encoded.toCore();
        encode(AMQPConverter.getInstance().fromCore(intermediate));
    }
    long totalDuration = 0;
    long startTime = System.nanoTime();
    for (int i = 0; i < PROFILE_CYCLES; ++i) {
        ICoreMessage intermediate = encoded.toCore();
        encode(AMQPConverter.getInstance().fromCore(intermediate));
    }
    totalDuration += System.nanoTime() - startTime;
    LOG_RESULTS(totalDuration);
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) 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