Search in sources :

Example 26 with PasProducer

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

the class BasicActiveMqProducerTest method testTopicProduceWithPerMessagePropertiesDisabled.

@Test
public void testTopicProduceWithPerMessagePropertiesDisabled() throws Exception {
    TopicLoopback echo = new TopicLoopback(activeMqBroker, getName());
    try {
        echo.start();
        PasProducer pasProducer = new PasProducer().withTopic(getName());
        pasProducer.setDeliveryMode(String.valueOf(DeliveryMode.PERSISTENT));
        pasProducer.setPriority(LOWEST_PRIORITY);
        pasProducer.setTtl(0L);
        pasProducer.setPerMessageProperties(false);
        StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), pasProducer);
        ExampleServiceCase.execute(standaloneProducer, createMessage());
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertEquals(LOWEST_PRIORITY, echo.getLastMessage().getJMSPriority());
        assertEquals(DeliveryMode.PERSISTENT, echo.getLastMessage().getJMSDeliveryMode());
    } finally {
        echo.stop();
    }
}
Also used : PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 27 with PasProducer

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

the class BasicActiveMqProducerTest method testTopicProduceAndConsume_WithEncoder.

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

Example 28 with PasProducer

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

the class BasicActiveMqProducerTest method testTopicProduceAndConsume.

@Test
public void testTopicProduceAndConsume() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    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) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 29 with PasProducer

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

the class BasicActiveMqProducerTest method testTopicProduce_WithStaticReplyTo.

@Test
public void testTopicProduce_WithStaticReplyTo() throws Exception {
    TopicLoopback echo = new TopicLoopback(activeMqBroker, getName());
    try {
        echo.start();
        StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
        AdaptrisMessage msg = EmbeddedActiveMq.createMessage(null);
        msg.addMetadata(JmsConstants.JMS_ASYNC_STATIC_REPLY_TO, getName() + "_reply");
        ExampleServiceCase.execute(standaloneProducer, msg);
        echo.waitFor(DEFAULT_TIMEOUT);
        assertNotNull(echo.getLastMessage());
        assertNotNull(echo.getLastMessage().getJMSReplyTo());
        assertEquals("topic://" + getName() + "_reply", echo.getLastMessage().getJMSReplyTo().toString());
    } finally {
        echo.stop();
    }
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 30 with PasProducer

use of com.adaptris.core.jms.PasProducer 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)

Aggregations

PasProducer (com.adaptris.core.jms.PasProducer)37 StandaloneProducer (com.adaptris.core.StandaloneProducer)34 Test (org.junit.Test)34 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)15 PasConsumer (com.adaptris.core.jms.PasConsumer)15 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)15 JmsConnection (com.adaptris.core.jms.JmsConnection)12 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)11 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)7 Channel (com.adaptris.core.Channel)5 MockChannel (com.adaptris.core.stubs.MockChannel)5 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)5 KeyValuePair (com.adaptris.util.KeyValuePair)5 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)4 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)4 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3 RequiresCredentialsBroker (com.adaptris.core.jms.activemq.RequiresCredentialsBroker)3 DefinedJmsProducer (com.adaptris.core.jms.DefinedJmsProducer)2 TimeInterval (com.adaptris.util.TimeInterval)2 MimeEncoder (com.adaptris.core.MimeEncoder)1