use of com.adaptris.core.Channel in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method createStartableChannel.
private Channel createStartableChannel(EmbeddedActiveMq mq, boolean isPtp, String threadName, String dest) throws Exception {
Channel channel = createPlainChannel(mq, isPtp);
channel.getWorkflowList().add(createWorkflow(isPtp, threadName, dest));
// channel.prepare();
return channel;
}
use of com.adaptris.core.Channel 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.Channel 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));
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesOrderedUsingQueue.
@Test
public void testMessagesOrderedUsingQueue() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testMessagesOrderedUsingQueue", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.getServiceCollection().addService(new RandomlyFail());
try {
channel.requestStart();
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
start(sender);
for (int i = 0; i < msgCount; i++) {
sender.doService(AdaptrisMessageFactory.getDefaultInstance().newMessage("" + i));
}
stop(sender);
waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
List<AdaptrisMessage> receivedList = ((MockMessageProducer) workflow.getProducer()).getMessages();
assertEquals(msgCount, receivedList.size());
for (int i = 0; i < msgCount; i++) {
assertEquals(String.valueOf(i), receivedList.get(i).getContent());
}
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.core.Channel in project interlok by adaptris.
the class LargeMessageWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
LargeMessageWorkflow workflow = new LargeMessageWorkflow();
workflow.setConsumer(new LargeFsConsumer().withBaseDirectoryUrl("file:////path/to/consume/directory"));
workflow.setProducer(new LargeFsProducer().withBaseDirectoryUrl("file:////path/to/produce/directory"));
c.getWorkflowList().add(workflow);
c.setUniqueId(UUID.randomUUID().toString());
workflow.setUniqueId(UUID.randomUUID().toString());
return c;
}
Aggregations