Search in sources :

Example 1 with BytesMessageTranslator

use of com.adaptris.core.jms.BytesMessageTranslator in project interlok by adaptris.

the class BasicActiveMqConsumerTest method testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation.

@Test
public void testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new AutoConvertMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    DefinedJmsProducer producer = new PasProducer().withTopic(getName());
    producer.setMessageTranslator(new BytesMessageTranslator());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : DefinedJmsProducer(com.adaptris.core.jms.DefinedJmsProducer) AutoConvertMessageTranslator(com.adaptris.core.jms.AutoConvertMessageTranslator) PasConsumer(com.adaptris.core.jms.PasConsumer) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 2 with BytesMessageTranslator

use of com.adaptris.core.jms.BytesMessageTranslator in project interlok by adaptris.

the class BasicActiveMqProducerTest method testQueueProduceAndConsumeWrongType.

@Test
public void testQueueProduceAndConsumeWrongType() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new BytesMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) PtpProducer(com.adaptris.core.jms.PtpProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 3 with BytesMessageTranslator

use of com.adaptris.core.jms.BytesMessageTranslator in project interlok by adaptris.

the class BasicActiveMqProducerTest method testTopicProduceAndConsumeWrongType.

@Test
public void testTopicProduceAndConsumeWrongType() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new BytesMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) PasProducer(com.adaptris.core.jms.PasProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 4 with BytesMessageTranslator

use of com.adaptris.core.jms.BytesMessageTranslator in project interlok by adaptris.

the class BasicActiveMqProducerTest method testTopicRequestReplyWithMessageWrongType.

@Test
public void testTopicRequestReplyWithMessageWrongType() throws Exception {
    TopicLoopback echo = new TopicLoopback(activeMqBroker, getName(), false);
    try {
        echo.start();
        PasProducer producer = new PasProducer().withTopic(getName());
        producer.setMessageTranslator(new BytesMessageTranslator());
        StandaloneRequestor req = new StandaloneRequestor(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
        AdaptrisMessage msg = createMessage();
        ExampleServiceCase.execute(req, msg);
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertNotNull(echo.getLastMessage().getJMSReplyTo());
    } finally {
        echo.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PasProducer(com.adaptris.core.jms.PasProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) Test(org.junit.Test)

Example 5 with BytesMessageTranslator

use of com.adaptris.core.jms.BytesMessageTranslator in project interlok by adaptris.

the class BasicActiveMqProducerTest method testQueueRequestReplyWithMessageWrongType.

@Test
public void testQueueRequestReplyWithMessageWrongType() throws Exception {
    QueueLoopback echo = new QueueLoopback(activeMqBroker, getName(), false);
    try {
        echo.start();
        PtpProducer producer = new PtpProducer().withQueue((getName()));
        producer.setMessageTranslator(new BytesMessageTranslator());
        StandaloneRequestor standaloneProducer = new StandaloneRequestor(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
        AdaptrisMessage msg = createMessage();
        ExampleServiceCase.execute(standaloneProducer, msg);
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertNotNull(echo.getLastMessage().getJMSReplyTo());
        assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
    } finally {
        echo.stop();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) Test(org.junit.Test)

Aggregations

BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)8 Test (org.junit.Test)8 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)6 StandaloneProducer (com.adaptris.core.StandaloneProducer)6 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)6 DefinedJmsProducer (com.adaptris.core.jms.DefinedJmsProducer)4 PasProducer (com.adaptris.core.jms.PasProducer)4 PtpProducer (com.adaptris.core.jms.PtpProducer)4 PasConsumer (com.adaptris.core.jms.PasConsumer)3 PtpConsumer (com.adaptris.core.jms.PtpConsumer)3 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)2 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)2 AutoConvertMessageTranslator (com.adaptris.core.jms.AutoConvertMessageTranslator)2