Search in sources :

Example 26 with StandaloneConsumer

use of com.adaptris.core.StandaloneConsumer 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 27 with StandaloneConsumer

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

the class ActiveMqPasPollingConsumerTest method testProduceConsume.

@Test
public void testProduceConsume() throws Exception {
    int msgCount = 5;
    final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(testName.getMethodName()));
    final StandaloneConsumer receiver = createStandalone(activeMqBroker, "testProduceConsume", testName.getMethodName());
    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 : 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 StandaloneConsumer

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

the class AdvancedActiveMqConsumerTest method retrieveObjectForSampleConfig.

@Override
protected Object retrieveObjectForSampleConfig() {
    JmsConnection connection = new JmsConnection();
    PtpConsumer producer = new PtpConsumer();
    producer.setQueue("destination");
    UrlVendorImplementation vendorImpl = createImpl();
    vendorImpl.setBrokerUrl(BasicActiveMqImplementationTest.PRIMARY);
    connection.setUserName("BrokerUsername");
    connection.setPassword("BrokerPassword");
    connection.setVendorImplementation(vendorImpl);
    StandaloneConsumer result = new StandaloneConsumer();
    result.setConnection(connection);
    result.setConsumer(producer);
    return result;
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) UrlVendorImplementation(com.adaptris.core.jms.UrlVendorImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) StandaloneConsumer(com.adaptris.core.StandaloneConsumer)

Example 29 with StandaloneConsumer

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

the class AdvancedActiveMqProducerTest method testQueueProduceAndConsumeWithPrefetch.

@Test
public void testQueueProduceAndConsumeWithPrefetch() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl(null, createPrefetch())), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl(null, createPrefetch())), 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) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 30 with StandaloneConsumer

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

the class AdvancedActiveMqProducerTest method testQueueProduceAndConsumeWithRedeliveryPolicy.

@Test
public void testQueueProduceAndConsumeWithRedeliveryPolicy() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl(createRedelivery(), null)), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl(createRedelivery(), null)), 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) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Aggregations

StandaloneConsumer (com.adaptris.core.StandaloneConsumer)188 Test (org.junit.Test)164 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)160 StandaloneProducer (com.adaptris.core.StandaloneProducer)91 TimeInterval (com.adaptris.util.TimeInterval)49 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)37 File (java.io.File)31 GuidGenerator (com.adaptris.util.GuidGenerator)30 FakeFtpServer (org.mockftpserver.fake.FakeFtpServer)30 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 FilenameFilter (java.io.FilenameFilter)24 RandomAccessFile (java.io.RandomAccessFile)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 PtpProducer (com.adaptris.core.jms.PtpProducer)23 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)22 QuartzCronPoller (com.adaptris.core.QuartzCronPoller)17 CoreException (com.adaptris.core.CoreException)16 PasProducer (com.adaptris.core.jms.PasProducer)15 LargeFsConsumer (com.adaptris.core.lms.LargeFsConsumer)15 PasConsumer (com.adaptris.core.jms.PasConsumer)14