Search in sources :

Example 36 with StandaloneConsumer

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

the class BasicActiveMqProducerTest method testBlobProduceConsume.

@Test
public void testBlobProduceConsume() throws Exception {
    if (!ExternalResourcesHelper.isExternalServerAvailable()) {
        log.debug("Blob Server not available; skipping test");
        return;
    }
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new BlobMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    PtpProducer producer = new PtpProducer().withQueue((getName()));
    producer.setMessageTranslator(new BlobMessageTranslator("blobUrl"));
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, addBlobUrlRef(EmbeddedActiveMq.createMessage(null), "blobUrl"), jms);
    assertMessages(jms, 1, false);
}
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 37 with StandaloneConsumer

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

the class BasicActiveMqProducerTest method testTopicProduceAndConsumeWrongType.

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

Example 38 with StandaloneConsumer

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsume_ObjectEndpoint.

@Test
public void testQueueProduceAndConsume_ObjectEndpoint() throws Exception {
    Queue queue = activeMqBroker.createQueue(getName());
    PtpConsumer consumer = new PtpConsumer().withQueue(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 PtpProducer().withQueue("%messageObject{objectEndpoint}"));
    AdaptrisMessage msg = createMessage();
    msg.addObjectHeader("objectEndpoint", queue);
    execute(standaloneConsumer, standaloneProducer, msg, jms);
    assertMessages(jms, 1);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) PtpProducer(com.adaptris.core.jms.PtpProducer) 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 39 with StandaloneConsumer

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

the class BasicActiveMqProducerTest method testTopicProduceAndConsume_DurableSubscriber.

@Test
public // INTERLOK-3537, if subscriptionId != "", then it should be durable.
void testTopicProduceAndConsume_DurableSubscriber() throws Exception {
    String subscriptionId = GUID.safeUUID();
    String clientId = GUID.safeUUID();
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setSubscriptionId(subscriptionId);
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl(), true);
    conn.setClientId(clientId);
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    // Start it once to get some durable Action.
    start(standaloneConsumer);
    stop(standaloneConsumer);
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
    int count = 10;
    for (int i = 0; i < count; i++) {
        ExampleServiceCase.execute(standaloneProducer, createMessage());
    }
    start(standaloneConsumer);
    waitForMessages(jms, count);
    assertMessages(jms, 10);
}
Also used : PasConsumer(com.adaptris.core.jms.PasConsumer) JmsConnection(com.adaptris.core.jms.JmsConnection) 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 40 with StandaloneConsumer

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

the class BasicActiveMqProducerTest method testQueueProduceAndConsume_ResolveableEndpoint.

@Test
public void testQueueProduceAndConsume_ResolveableEndpoint() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(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 PtpProducer().withQueue("%message{metadataEndpoint}"));
    AdaptrisMessage msg = createMessage();
    msg.addMessageHeader("metadataEndpoint", getName());
    execute(standaloneConsumer, standaloneProducer, msg, jms);
    assertMessages(jms, 1);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) 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