Search in sources :

Example 51 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JmsProducerTest method testProduceAndConsume_DeliveryMode.

@Test
public void testProduceAndConsume_DeliveryMode() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "?deliveryMode=PERSISTENT";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(rfc6167);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 52 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JmsProducerTest method testProduceAndConsume_TimeToLive.

@Test
public void testProduceAndConsume_TimeToLive() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "?timeToLive=60000";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(rfc6167);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 53 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JmsProducerTest method testProduceAndConsume_ResolvedEndpoint.

@Test
public void testProduceAndConsume_ResolvedEndpoint() throws Exception {
    Queue queue = activeMqBroker.createQueue(getName());
    String endpoint = "%message{metadataEndpoint}";
    String rfc6167 = "jms:queue:" + getName();
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(endpoint);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    AdaptrisMessage msg = createMessage();
    msg.addMessageHeader("metadataEndpoint", rfc6167);
    execute(standaloneConsumer, standaloneProducer, msg, jms);
    assertMessages(jms, 1);
}
Also used : AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Queue(javax.jms.Queue) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 54 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JmsProducerTest method testProduceAndConsume_Priority.

@Test
public void testProduceAndConsume_Priority() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "?priority=5";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode(String.valueOf(AcknowledgeMode.Mode.AUTO_ACKNOWLEDGE.acknowledgeMode()));
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    JmsProducer producer = createProducer(rfc6167);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
    assertMessages(jms, 1);
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 55 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.

the class JmsProducerTest method testDefaultSessionFactory.

@Test
public void testDefaultSessionFactory() throws Exception {
    String rfc6167 = "jms:queue:" + getName() + "";
    JmsConsumerImpl consumer = createConsumer(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
    MockMessageListener jms = new MockMessageListener();
    JmsProducer producer = createProducer(rfc6167);
    producer.setSessionFactory(new DefaultProducerSessionFactory());
    StandaloneProducer sp = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    try {
        start(standaloneConsumer, sp);
        sp.doService(createMessage());
        sp.doService(createMessage());
        waitForMessages(jms, 2);
        assertMessages(jms, 2);
    } finally {
        stop(sp, standaloneConsumer);
    }
}
Also used : StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneProducer (com.adaptris.core.StandaloneProducer)266 Test (org.junit.Test)238 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)125 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)91 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)91 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)68 Channel (com.adaptris.core.Channel)64 PtpProducer (com.adaptris.core.jms.PtpProducer)46 ServiceList (com.adaptris.core.ServiceList)39 PasProducer (com.adaptris.core.jms.PasProducer)34 JettyHelper.createChannel (com.adaptris.core.http.jetty.JettyHelper.createChannel)32 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)27 HttpConsumerTest (com.adaptris.core.http.jetty.HttpConsumerTest)23 PtpConsumer (com.adaptris.core.jms.PtpConsumer)23 TimeInterval (com.adaptris.util.TimeInterval)23 MockChannel (com.adaptris.core.stubs.MockChannel)22 ServiceException (com.adaptris.core.ServiceException)20 StandardWorkflow (com.adaptris.core.StandardWorkflow)20 HttpConnection (com.adaptris.core.http.jetty.HttpConnection)20 JettyMessageConsumer (com.adaptris.core.http.jetty.JettyMessageConsumer)20