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;
}
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;
}
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);
}
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);
}
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();
}
}
Aggregations