Search in sources :

Example 1 with ServerJMSTextMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method testConvertTextMessageCreatesAmqpValueStringBody.

@Test
public void testConvertTextMessageCreatesAmqpValueStringBody() throws Exception {
    String contentString = "myTextMessageContent";
    ServerJMSTextMessage outbound = createTextMessage(contentString);
    outbound.encode();
    Message amqp = AMQPConverter.getInstance().fromCore(outbound.getInnerMessage()).getProtonMessage();
    assertNotNull(amqp.getBody());
    assertTrue(amqp.getBody() instanceof AmqpValue);
    assertEquals(contentString, ((AmqpValue) amqp.getBody()).getValue());
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 2 with ServerJMSTextMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method doTestConvertMessageWithJMSDestination.

private void doTestConvertMessageWithJMSDestination(ServerDestination jmsDestination, Object expectedAnnotationValue) throws Exception {
    ServerJMSTextMessage textMessage = createTextMessage();
    textMessage.setText("myTextMessageContent");
    textMessage.setJMSDestination(jmsDestination);
    Message amqp = AMQPConverter.getInstance().fromCore(textMessage.getInnerMessage()).getProtonMessage();
    MessageAnnotations ma = amqp.getMessageAnnotations();
    Map<Symbol, Object> maMap = ma == null ? null : ma.getValue();
    if (maMap != null) {
        Object actualValue = maMap.get(AMQPMessageSupport.JMS_DEST_TYPE_MSG_ANNOTATION);
        assertEquals("Unexpected annotation value", expectedAnnotationValue, actualValue);
    } else if (expectedAnnotationValue != null) {
        fail("Expected annotation value, but there were no annotations");
    }
    if (jmsDestination != null) {
        assertEquals("Unexpected 'to' address", jmsDestination.getAddress(), amqp.getAddress());
    }
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) MessageAnnotations(org.apache.qpid.proton.amqp.messaging.MessageAnnotations) Symbol(org.apache.qpid.proton.amqp.Symbol)

Example 3 with ServerJMSTextMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage in project activemq-artemis by apache.

the class TestConversions method testSimpleConversionText.

@Test
public void testSimpleConversionText() throws Exception {
    Map<String, Object> mapprop = createPropertiesMap();
    ApplicationProperties properties = new ApplicationProperties(mapprop);
    MessageImpl message = (MessageImpl) Message.Factory.create();
    message.setApplicationProperties(properties);
    String text = "someText";
    message.setBody(new AmqpValue(text));
    AMQPMessage encodedMessage = new AMQPMessage(message);
    ICoreMessage serverMessage = encodedMessage.toCore();
    ServerJMSTextMessage textMessage = (ServerJMSTextMessage) ServerJMSMessage.wrapCoreMessage(serverMessage);
    textMessage.decode();
    verifyProperties(textMessage);
    Assert.assertEquals(text, textMessage.getText());
}
Also used : ICoreMessage(org.apache.activemq.artemis.api.core.ICoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) 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) AmqpValue(org.apache.qpid.proton.amqp.messaging.AmqpValue) Test(org.junit.Test)

Example 4 with ServerJMSTextMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage in project activemq-artemis by apache.

the class AMQPMessageSupport method createTextMessage.

public static ServerJMSTextMessage createTextMessage(long id, String text, CoreMessageObjectPools coreMessageObjectPools) throws JMSException {
    ServerJMSTextMessage message = createTextMessage(id, coreMessageObjectPools);
    message.setText(text);
    return message;
}
Also used : ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage)

Example 5 with ServerJMSTextMessage

use of org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage in project activemq-artemis by apache.

the class JMSMappingOutboundTransformerTest method doTestConvertMessageWithJMSReplyTo.

private void doTestConvertMessageWithJMSReplyTo(ServerDestination jmsReplyTo, Object expectedAnnotationValue) throws Exception {
    ServerJMSTextMessage textMessage = createTextMessage();
    textMessage.setText("myTextMessageContent");
    textMessage.setJMSReplyTo(jmsReplyTo);
    Message amqp = AMQPConverter.getInstance().fromCore(textMessage.getInnerMessage()).getProtonMessage();
    MessageAnnotations ma = amqp.getMessageAnnotations();
    Map<Symbol, Object> maMap = ma == null ? null : ma.getValue();
    if (maMap != null) {
        Object actualValue = maMap.get(AMQPMessageSupport.JMS_REPLY_TO_TYPE_MSG_ANNOTATION);
        assertEquals("Unexpected annotation value", expectedAnnotationValue, actualValue);
    } else if (expectedAnnotationValue != null) {
        fail("Expected annotation value, but there were no annotations");
    }
    if (jmsReplyTo != null) {
        assertEquals("Unexpected 'reply-to' address", jmsReplyTo.getAddress(), amqp.getReplyTo());
    }
}
Also used : CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) ServerJMSObjectMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage) Message(org.apache.qpid.proton.message.Message) ServerJMSMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage) ServerJMSStreamMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage) ServerJMSBytesMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage) ServerJMSMapMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage) ServerJMSTextMessage(org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage) MessageAnnotations(org.apache.qpid.proton.amqp.messaging.MessageAnnotations) Symbol(org.apache.qpid.proton.amqp.Symbol)

Aggregations

ServerJMSTextMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSTextMessage)10 ServerJMSBytesMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSBytesMessage)8 ServerJMSMapMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMapMessage)8 ServerJMSMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSMessage)8 ServerJMSObjectMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSObjectMessage)8 ServerJMSStreamMessage (org.apache.activemq.artemis.protocol.amqp.converter.jms.ServerJMSStreamMessage)8 AmqpValue (org.apache.qpid.proton.amqp.messaging.AmqpValue)7 Message (org.apache.qpid.proton.message.Message)7 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)6 Test (org.junit.Test)6 ICoreMessage (org.apache.activemq.artemis.api.core.ICoreMessage)3 AMQPMessage (org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessage)2 Symbol (org.apache.qpid.proton.amqp.Symbol)2 MessageAnnotations (org.apache.qpid.proton.amqp.messaging.MessageAnnotations)2 ArrayList (java.util.ArrayList)1 MessageEOFException (javax.jms.MessageEOFException)1 TextMessage (javax.jms.TextMessage)1 Binary (org.apache.qpid.proton.amqp.Binary)1 AmqpSequence (org.apache.qpid.proton.amqp.messaging.AmqpSequence)1 ApplicationProperties (org.apache.qpid.proton.amqp.messaging.ApplicationProperties)1