use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsSyncConsumerTest method testQueue_ProduceConsume.
@Test
public void testQueue_ProduceConsume() throws Exception {
int msgCount = 5;
String rfc6167 = "jms:queue:" + testName.getMethodName();
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
final StandaloneConsumer receiver = createStandaloneConsumer(activeMqBroker, testName.getMethodName(), rfc6167);
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(sender);
LifecycleHelper.prepare(receiver);
start(receiver);
start(sender);
for (int i = 0; i < msgCount; i++) {
sender.doService(createMessage());
}
waitForMessages(jms, msgCount);
assertMessages(jms, msgCount);
} finally {
shutdownQuietly(sender, receiver);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesRolledBackUsingQueue.
@Test
public void testMessagesRolledBackUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesRolledBackUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesCommittedUsingQueue.
@Test
public void testMessagesCommittedUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesCommittedUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue(destination));
send(sender, msgCount);
waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testWorkflow_SkipProducer.
@Test
public void testWorkflow_SkipProducer() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testWorkflow_SkipProducer", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer serviceProducer = new MockMessageProducer();
workflow.getServiceCollection().addAll(Arrays.asList(new Service[] { new StandaloneProducer(serviceProducer), new MockSkipProducerService() }));
MockMessageProducer workflowProducer = (MockMessageProducer) workflow.getProducer();
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
waitForMessages(serviceProducer, msgCount);
assertEquals(msgCount, serviceProducer.messageCount());
assertEquals(0, workflowProducer.messageCount());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testServiceException.
@Test
public void testServiceException() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testServiceException", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
} finally {
channel.requestClose();
}
assertEquals(msgCount, activeMqBroker.messagesOnQueue(destination));
}
Aggregations