Search in sources :

Example 1 with PtpConsumer

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

the class ActiveMqJmsTransactedWorkflowTest method createWorkflow.

private JmsTransactedWorkflow createWorkflow(boolean isPtp, String threadName, String target) throws CoreException {
    JmsTransactedWorkflow workflow = new JmsTransactedWorkflow();
    workflow.setWaitPeriodAfterRollback(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
    workflow.setProducer(new MockMessageProducer());
    JmsConsumerImpl jmsCons = isPtp ? new PtpConsumer().withQueue(target) : new PasConsumer().withTopic(target);
    jmsCons.setMessageTranslator(new TextMessageTranslator().withMoveJmsHeaders(true));
    workflow.setConsumer(jmsCons);
    return workflow;
}
Also used : PtpConsumer(com.adaptris.core.jms.PtpConsumer) TimeInterval(com.adaptris.util.TimeInterval) MockMessageProducer(com.adaptris.core.stubs.MockMessageProducer) PasConsumer(com.adaptris.core.jms.PasConsumer) TextMessageTranslator(com.adaptris.core.jms.TextMessageTranslator) JmsTransactedWorkflow(com.adaptris.core.jms.JmsTransactedWorkflow) JmsConsumerImpl(com.adaptris.core.jms.JmsConsumerImpl)

Example 2 with PtpConsumer

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

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

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

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

Aggregations

PtpConsumer (com.adaptris.core.jms.PtpConsumer)27 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)24 PtpProducer (com.adaptris.core.jms.PtpProducer)24 StandaloneProducer (com.adaptris.core.StandaloneProducer)23 Test (org.junit.Test)23 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)22 JmsConnection (com.adaptris.core.jms.JmsConnection)5 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 BytesMessageTranslator (com.adaptris.core.jms.BytesMessageTranslator)3 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)3 DefinedJmsProducer (com.adaptris.core.jms.DefinedJmsProducer)2 TextMessageTranslator (com.adaptris.core.jms.TextMessageTranslator)2 UrlVendorImplementation (com.adaptris.core.jms.UrlVendorImplementation)2 FileBackedMessageFactory (com.adaptris.core.lms.FileBackedMessageFactory)2 MockChannel (com.adaptris.core.stubs.MockChannel)2 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)2 Channel (com.adaptris.core.Channel)1 MimeEncoder (com.adaptris.core.MimeEncoder)1 StandardWorkflow (com.adaptris.core.StandardWorkflow)1 AutoConvertMessageTranslator (com.adaptris.core.jms.AutoConvertMessageTranslator)1