use of com.adaptris.core.StandaloneProducer 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.StandaloneProducer in project interlok by adaptris.
the class JmsConnectionErrorHandlerTest method createProducer.
private StandaloneProducer createProducer(EmbeddedActiveMq mq, String dest) {
JmsConnection conn = mq.getJmsConnection(new BasicActiveMqImplementation(), true);
conn.setConnectionErrorHandler(new JmsConnectionErrorHandler());
PasProducer producer = new PasProducer().withTopic(dest);
return new StandaloneProducer(conn, producer);
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JndiPasProducerCase method testProduceJndiOnlyObjectNotFound.
@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation sendVendorImp = createVendorImplementation();
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, true, queueName, topicName), new PasProducer().withTopic(this.getClass().getSimpleName()));
try {
start(standaloneProducer);
standaloneProducer.produce(createMessage(null));
fail("Expected ProduceException");
} catch (ProduceException expected) {
} finally {
stop(standaloneProducer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceJndiOnlyObjectNotFound.
@Test
public void testProduceJndiOnlyObjectNotFound() throws Exception {
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation sendVendorImp = createVendorImplementation();
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((this.getClass().getSimpleName())));
try {
start(standaloneProducer);
standaloneProducer.produce(createMessage(null));
fail("Expected ProduceException");
} catch (ProduceException expected) {
} finally {
stop(standaloneProducer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsumeUsingJndiOnly.
@Test
public void testProduceAndConsumeUsingJndiOnly() throws Exception {
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, true, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, true, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
Aggregations