Search in sources :

Example 6 with PtpProducer

use of com.adaptris.core.jms.PtpProducer 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 7 with PtpProducer

use of com.adaptris.core.jms.PtpProducer 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 8 with PtpProducer

use of com.adaptris.core.jms.PtpProducer 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 9 with PtpProducer

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

Example 10 with PtpProducer

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

the class BasicActiveMqImplementationTest method testRfc6167_WithParams.

@Test
public void testRfc6167_WithParams() 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?replyToName=StaticReplyTo&priority=1&deliveryMode=NON_PERSISTENT&timeToLive=1000", ptp);
        assertNotNull(jmsDest.getDestination());
        assertTrue(javax.jms.Queue.class.isAssignableFrom(jmsDest.getDestination().getClass()));
        assertNotNull(jmsDest.getReplyToDestination());
        assertTrue(javax.jms.Queue.class.isAssignableFrom(jmsDest.getReplyToDestination().getClass()));
        assertNotNull(jmsDest.deliveryMode());
        assertEquals("NON_PERSISTENT", jmsDest.deliveryMode());
        assertNotNull(jmsDest.priority());
        assertEquals(Integer.valueOf(1), jmsDest.priority());
        assertNotNull(jmsDest.timeToLive());
        assertEquals(Long.valueOf(1000), 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

PtpProducer (com.adaptris.core.jms.PtpProducer)52 StandaloneProducer (com.adaptris.core.StandaloneProducer)46 Test (org.junit.Test)46 PtpConsumer (com.adaptris.core.jms.PtpConsumer)24 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)23 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)23 MockChannel (com.adaptris.core.stubs.MockChannel)14 Channel (com.adaptris.core.Channel)13 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)12 JmsTransactedWorkflow (com.adaptris.core.jms.JmsTransactedWorkflow)12 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)10 JmsConnection (com.adaptris.core.jms.JmsConnection)8 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)6 ThrowExceptionService (com.adaptris.core.services.exception.ThrowExceptionService)6 ConfiguredException (com.adaptris.core.services.exception.ConfiguredException)5 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)4 TimeInterval (com.adaptris.util.TimeInterval)4 ProduceException (com.adaptris.core.ProduceException)3 Service (com.adaptris.core.Service)3 StandaloneRequestor (com.adaptris.core.StandaloneRequestor)3