Search in sources :

Example 71 with StandaloneProducer

use of com.adaptris.core.StandaloneProducer 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)

Example 72 with StandaloneProducer

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

the class BasicActiveMqConsumerTest method testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation.

@Test
public void testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation() throws Exception {
    PasConsumer consumer = new PasConsumer().withTopic(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    consumer.setMessageTranslator(new AutoConvertMessageTranslator());
    StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
    MockMessageListener jms = new MockMessageListener();
    standaloneConsumer.registerAdaptrisMessageListener(jms);
    DefinedJmsProducer producer = new PasProducer().withTopic(getName());
    producer.setMessageTranslator(new BytesMessageTranslator());
    StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
    execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
    assertMessages(jms, 1);
}
Also used : DefinedJmsProducer(com.adaptris.core.jms.DefinedJmsProducer) AutoConvertMessageTranslator(com.adaptris.core.jms.AutoConvertMessageTranslator) PasConsumer(com.adaptris.core.jms.PasConsumer) PasProducer(com.adaptris.core.jms.PasProducer) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) MockMessageListener(com.adaptris.core.stubs.MockMessageListener) BytesMessageTranslator(com.adaptris.core.jms.BytesMessageTranslator) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 73 with StandaloneProducer

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

the class BasicActiveMqConsumerTest method testQueue_ProduceWhenConsumerStopped.

@Test
public void testQueue_ProduceWhenConsumerStopped() throws Exception {
    PtpConsumer consumer = new PtpConsumer().withQueue(getName());
    consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
    StandardWorkflow workflow = new StandardWorkflow();
    MockMessageProducer producer = new MockMessageProducer();
    workflow.setConsumer(consumer);
    workflow.setProducer(producer);
    Channel channel = createChannel(activeMqBroker.getJmsConnection(createVendorImpl()), workflow);
    try {
        StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PtpProducer().withQueue((getName())));
        channel.requestStart();
        workflow.requestStop();
        start(standaloneProducer);
        AdaptrisMessage msg = createMessage(null);
        standaloneProducer.produce(msg);
        Thread.sleep(250);
        assertEquals(0, producer.messageCount());
        stop(standaloneProducer);
    } finally {
        channel.requestClose();
    }
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) StandardWorkflow(com.adaptris.core.StandardWorkflow) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) PtpProducer(com.adaptris.core.jms.PtpProducer) StandaloneProducer(com.adaptris.core.StandaloneProducer) Test(org.junit.Test)

Example 74 with StandaloneProducer

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

the class BasicActiveMqConsumerTest method testBlobProduceAndConsumeWithFileMessageFactory.

@Test
public void testBlobProduceAndConsumeWithFileMessageFactory() 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(createMessage(new FileBackedMessageFactory()), "blobUrl"), jms);
    assertMessages(jms, 1, false);
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) FileBackedMessageFactory(com.adaptris.core.lms.FileBackedMessageFactory) 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 75 with StandaloneProducer

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

the class BasicActiveMqImplementationTest method testRfc6167_Basic.

@Test
public void testRfc6167_Basic() throws Exception {
    StandaloneProducer producer = null;
    try {
        BasicActiveMqImplementation vendorImp = create();
        PtpProducer ptp = new PtpProducer().withQueue((testName.getMethodName()));
        producer = new StandaloneProducer(activeMqBroker.getJmsConnection(vendorImp), ptp);
        start(producer);
        // Send a message so that the session is correct.
        producer.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("abcde"));
        JmsDestination jmsDest = vendorImp.createDestination("jms:queue:myQueueName", ptp);
        assertNotNull(jmsDest.getDestination());
        assertTrue(javax.jms.Queue.class.isAssignableFrom(jmsDest.getDestination().getClass()));
        assertNull(jmsDest.deliveryMode());
        assertNull(jmsDest.getReplyToDestination());
        assertNull(jmsDest.priority());
        assertNull(jmsDest.timeToLive());
        assertNull(jmsDest.subscriptionId());
        assertFalse(jmsDest.noLocal());
    } finally {
        stop(producer);
    }
}
Also used : PtpProducer(com.adaptris.core.jms.PtpProducer) JmsDestination(com.adaptris.core.jms.JmsDestination) 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