Search in sources :

Example 21 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method doTransformWithToTypeDestinationTypeAnnotationTestImpl.

private void doTransformWithToTypeDestinationTypeAnnotationTestImpl(Object toTypeAnnotationValue, Class<? extends Destination> expectedClass) throws Exception {
    String toAddress = "toAddress";
    Message amqp = Message.Factory.create();
    amqp.setBody(new AmqpValue("myTextMessageContent"));
    amqp.setAddress(toAddress);
    if (toTypeAnnotationValue != null) {
        Map<Symbol, Object> map = new HashMap<>();
        map.put(Symbol.valueOf("x-opt-to-type"), toTypeAnnotationValue);
        MessageAnnotations ma = new MessageAnnotations(map);
        amqp.setMessageAnnotations(ma);
    }
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(amqp).toCore());
    assertTrue("Expected TextMessage", jmsMessage instanceof TextMessage);
}
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) Symbol(org.apache.qpid.proton.amqp.Symbol) MessageAnnotations(org.apache.qpid.proton.amqp.messaging.MessageAnnotations) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) TextMessage(javax.jms.TextMessage)

Example 22 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateTextMessageFromNoBodySectionAndContentType.

@Test
public void testCreateTextMessageFromNoBodySectionAndContentType() throws Exception {
    Message message = Message.Factory.create();
    message.setContentType("text/plain");
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSTextMessage.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) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 23 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateBytesMessageFromAmqpValueWithUncategorisedContent.

/**
 * Test that an amqp-value body containing a value which can't be categorized results in an
 * exception from the transformer and then try the transformer's own fallback transformer to
 * result in an BytesMessage.
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateBytesMessageFromAmqpValueWithUncategorisedContent() throws Exception {
    Message message = Proton.message();
    message.setBody(new AmqpValue(UUID.randomUUID()));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.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) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 24 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateBytesMessageFromNoBodySectionAndContentType.

// ----- Null Body Section ------------------------------------------------//
/**
 * Test that a message with no body section, but with the content type set to
 * {@value AMQPMessageSupport#OCTET_STREAM_CONTENT_TYPE} results in a BytesMessage
 *
 * @throws Exception
 *         if an error occurs during the test.
 */
@Test
public void testCreateBytesMessageFromNoBodySectionAndContentType() throws Exception {
    Message message = Message.Factory.create();
    message.setContentType(AMQPMessageSupport.OCTET_STREAM_CONTENT_TYPE);
    AMQPMessage messageEncode = new AMQPMessage(message);
    ICoreMessage coreMessage = messageEncode.toCore();
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(coreMessage);
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSBytesMessage.class, jmsMessage.getClass());
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) 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) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) Test(org.junit.Test)

Example 25 with AMQPMessage

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

the class JMSMappingInboundTransformerTest method testCreateTextMessageFromAmqpValueWithString.

// ----- AmqpValue transformations ----------------------------------------//
/**
 * Test that an amqp-value body containing a string results in a TextMessage 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 testCreateTextMessageFromAmqpValueWithString() throws Exception {
    Message message = Proton.message();
    message.setBody(new AmqpValue("content"));
    javax.jms.Message jmsMessage = ServerJMSMessage.wrapCoreMessage(new AMQPMessage(message).toCore());
    assertNotNull("Message should not be null", jmsMessage);
    assertEquals("Unexpected message class type", ServerJMSTextMessage.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) AMQPMessage(org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) 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