use of com.adaptris.core.jms.PtpProducer 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);
}
use of com.adaptris.core.jms.PtpProducer in project interlok by adaptris.
the class JndiPtpProducerCase method testProduceAndConsume_ExtraConfig.
@Test
public void testProduceAndConsume_ExtraConfig() throws Exception {
SimpleFactoryConfiguration sfc = new SimpleFactoryConfiguration();
KeyValuePairSet kvps = new KeyValuePairSet();
kvps.add(new KeyValuePair("ClientID", "testProduceAndConsume_ExtraConfig"));
kvps.add(new KeyValuePair("UseCompression", "true"));
sfc.setProperties(kvps);
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
sendVendorImp.setExtraFactoryConfiguration(sfc);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPtpConnection(recvVendorImp, false, queueName, topicName), new PtpConsumer().withQueue(queueName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPtpConnection(sendVendorImp, false, queueName, topicName), new PtpProducer().withQueue((queueName)));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms);
}
use of com.adaptris.core.jms.PtpProducer in project interlok by adaptris.
the class RequestReplyWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
try {
c.setConsumeConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616")));
c.setProduceConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:2506")));
RequestReplyWorkflow workflow = new RequestReplyWorkflow();
workflow.getServiceCollection().addService(new Base64DecodeService());
workflow.setConsumer(new PtpConsumer().withQueue("inputQueue"));
workflow.setProducer(new PtpProducer().withQueue("outputQueue"));
workflow.setReplyProducer(new PtpProducer().withQueue("TODO"));
workflow.getReplyServiceCollection().addService(new Base64EncodeService());
c.getWorkflowList().add(workflow);
c.setUniqueId(UUID.randomUUID().toString());
workflow.setUniqueId(UUID.randomUUID().toString());
} catch (CoreException e) {
throw new RuntimeException(e);
}
return c;
}
use of com.adaptris.core.jms.PtpProducer in project interlok by adaptris.
the class AdapterTest method createRetryingAdapter.
/**
* <p>
* Creates a valid Adapter to use in tests. Uese Mock aka Memory MessageConsumer / Producer.
* </p>
*
* @param uniqueId a uniqure identifier for this <code>Adapter</code>
*/
public static Adapter createRetryingAdapter(String uniqueId) throws Exception {
Adapter result = null;
AdaptrisConnection consume = new NullConnection();
JmsConnection produce = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:5000"));
produce.setConnectionRetryInterval(new TimeInterval(1L, TimeUnit.SECONDS.name()));
produce.setConnectionAttempts(20);
AdaptrisMessageProducer producer1 = new PtpProducer().withQueue("dummyQueue");
StandardWorkflow workflow1 = new StandardWorkflow();
workflow1.setProducer(producer1);
WorkflowList workflows = new WorkflowList();
workflows.add(workflow1);
Channel channel = new Channel();
channel.setUniqueId(uniqueId + "_c1");
channel.setConsumeConnection(consume);
channel.setProduceConnection(produce);
channel.setWorkflowList(workflows);
ChannelList channels = new ChannelList();
channels.addChannel(channel);
result = new Adapter();
result.setChannelList(channels);
result.setUniqueId(uniqueId);
return result;
}
use of com.adaptris.core.jms.PtpProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testRuntimeException.
@Test
public void testRuntimeException() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, true, "testRuntimeException", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.setProducer(new MockMessageProducer() {
@Override
protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
throw new RuntimeException();
}
});
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