Search in sources :

Example 1 with PasPollingConsumer

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

the class ActiveMqPasPollingConsumerTest method createStandalone.

private StandaloneConsumer createStandalone(EmbeddedActiveMq mq, String threadName, String destinationName) throws Exception {
    PasPollingConsumer consumer = new PasPollingConsumer().withTopic(destinationName);
    consumer.setPoller(new Sometime());
    JmsConnection c = mq.getJmsConnection();
    consumer.setVendorImplementation(c.getVendorImplementation());
    consumer.setClientId(c.getClientId());
    consumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
    consumer.setReacquireLockBetweenMessages(true);
    consumer.setAdditionalDebug(true);
    consumer.setReceiveTimeout(new TimeInterval(Integer.valueOf(new Random().nextInt(100) + 100).longValue(), TimeUnit.MILLISECONDS));
    StandaloneConsumer sc = new StandaloneConsumer(consumer);
    return sc;
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) TimeInterval(com.adaptris.util.TimeInterval) Random(java.util.Random) ThreadLocalRandom(java.util.concurrent.ThreadLocalRandom) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 2 with PasPollingConsumer

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

the class ActiveMqPasPollingConsumerTest method testInitSubscriptionOnly.

@Test
public void testInitSubscriptionOnly() throws Exception {
    PasPollingConsumer consumer = create();
    consumer.setSubscriptionId("xxxx");
    try {
        consumer.init();
        fail("Should fail due to missing client Id");
    } catch (CoreException e) {
    // expected
    }
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 3 with PasPollingConsumer

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

the class ActiveMqPasPollingConsumerTest method testInitNoClientIdOrSubscriptionId.

@Test
public void testInitNoClientIdOrSubscriptionId() throws Exception {
    PasPollingConsumer consumer = create();
    try {
        consumer.init();
        fail("Should fail due to missing subscription Id, client Id");
    } catch (CoreException e) {
    // expected
    }
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 4 with PasPollingConsumer

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

the class ActiveMqPasPollingConsumerTest method testInitClientAndSubscriptionSet.

@Test
public void testInitClientAndSubscriptionSet() throws Exception {
    PasPollingConsumer consumer = create();
    consumer.setClientId("xxxx");
    consumer.setSubscriptionId("xxxx");
    try {
        consumer.init();
    } catch (CoreException e) {
        fail(e.getMessage());
    }
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 5 with PasPollingConsumer

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

the class ActiveMqPasPollingConsumerTest method create.

private static PasPollingConsumer create() {
    PasPollingConsumer consumer = new PasPollingConsumer().withTopic("destination");
    consumer.setVendorImplementation(new BasicActiveMqImplementation());
    consumer.registerAdaptrisMessageListener(new StandardWorkflow());
    return consumer;
}
Also used : PasPollingConsumer(com.adaptris.core.jms.PasPollingConsumer) StandardWorkflow(com.adaptris.core.StandardWorkflow)

Aggregations

PasPollingConsumer (com.adaptris.core.jms.PasPollingConsumer)6 CoreException (com.adaptris.core.CoreException)4 Test (org.junit.Test)4 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 JmsConnection (com.adaptris.core.jms.JmsConnection)1 TimeInterval (com.adaptris.util.TimeInterval)1 Random (java.util.Random)1 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)1