Search in sources :

Example 1 with JmsPollingConsumer

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

the class ActiveMqJmsPollingConsumerTest method createConsumer.

private JmsPollingConsumer createConsumer(EmbeddedActiveMq broker, String threadName, String destinationName, Poller poller) {
    JmsPollingConsumer consumer = new JmsPollingConsumer().withEndpoint(destinationName);
    consumer.setPoller(poller);
    JmsConnection c = broker.getJmsConnection();
    consumer.setClientId(c.configuredClientId());
    consumer.setUserName(c.configuredUserName());
    consumer.setPassword(c.configuredPassword());
    consumer.setReacquireLockBetweenMessages(true);
    consumer.setVendorImplementation(c.getVendorImplementation());
    return consumer;
}
Also used : JmsPollingConsumer(com.adaptris.core.jms.JmsPollingConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection)

Example 2 with JmsPollingConsumer

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

the class ActiveMqJmsPollingConsumerTest method testTopic_ProduceConsume.

@Test
public void testTopic_ProduceConsume() throws Exception {
    int msgCount = 5;
    String rfc6167 = "jms:topic:" + testName.getMethodName() + "?subscriptionId=" + testName.getMethodName();
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
    Sometime poller = new Sometime();
    JmsPollingConsumer consumer = createConsumer(activeMqBroker, testName.getMethodName(), rfc6167, poller);
    final StandaloneConsumer receiver = new StandaloneConsumer(consumer);
    try {
        MockMessageListener jms = new MockMessageListener();
        receiver.registerAdaptrisMessageListener(jms);
        startAndStop(receiver);
        start(receiver);
        start(sender);
        for (int i = 0; i < msgCount; i++) {
            sender.doService(createMessage());
        }
        waitForMessages(jms, msgCount);
        assertMessages(jms, msgCount);
    } finally {
        shutdownQuietly(sender, receiver);
    }
}
Also used : JmsProducer(com.adaptris.core.jms.JmsProducer) JmsPollingConsumer(com.adaptris.core.jms.JmsPollingConsumer) Sometime(com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

JmsPollingConsumer (com.adaptris.core.jms.JmsPollingConsumer)2 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)1 StandaloneProducer (com.adaptris.core.StandaloneProducer)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1 JmsProducer (com.adaptris.core.jms.JmsProducer)1 Sometime (com.adaptris.core.jms.activemq.ActiveMqPasPollingConsumerTest.Sometime)1 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)1 Test (org.junit.Test)1