use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class DestinationCacheJndiPasProducerTest method testProduceAndConsumeWithCache.
@Test
public void testProduceAndConsumeWithCache() throws Exception {
StandardJndiImplementation recvVendorImp = createVendorImplementation();
StandardJndiImplementation sendVendorImp = createVendorImplementation();
String queueName = testName.getMethodName() + "_queue";
String topicName = testName.getMethodName() + "_topic";
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJndiPasConnection(recvVendorImp, false, queueName, topicName), new PasConsumer().withTopic(topicName));
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJndiPasConnection(sendVendorImp, false, queueName, topicName), new PasProducer().withTopic(topicName));
try {
start(standaloneConsumer);
start(standaloneProducer);
standaloneProducer.doService(createMessage(null));
standaloneProducer.doService(createMessage(null));
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer);
stop(standaloneConsumer);
}
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testMessagesRolledBackUsingTopic.
@Test
public void testMessagesRolledBackUsingTopic() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
Channel channel = createStartableChannel(activeMqBroker, false, "testMessagesRolledBackUsingTopic", 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 PasProducer().withTopic(destination));
send(sender, msgCount);
assertEquals(0, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
// can't actually check the count of messsages on a topic, that's a trifle
// silly; you might check per-subscription...
// assertEquals(msgCount, activeMqBroker.messageCount(get(TOPIC)));
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class ActiveMqPasPollingConsumerTest method testProduceConsume.
@Test
public void testProduceConsume() throws Exception {
int msgCount = 5;
final StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PasProducer().withTopic(testName.getMethodName()));
final StandaloneConsumer receiver = createStandalone(activeMqBroker, "testProduceConsume", testName.getMethodName());
try {
MockMessageListener jms = new MockMessageListener();
receiver.registerAdaptrisMessageListener(jms);
startAndStop(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.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqConsumerTest method testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation.
@Test
public void testTopicProduceAndConsumeWithExplicitFallbackMessageTranslation() throws Exception {
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
consumer.setMessageTranslator(new AutoConvertMessageTranslator());
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl()), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
DefinedJmsProducer producer = new PasProducer().withTopic(getName());
producer.setMessageTranslator(new BytesMessageTranslator());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), producer);
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.jms.PasProducer in project interlok by adaptris.
the class BasicActiveMqProducerTest method testTopicProduceAndConsume_DurableSubscriber_Legacy.
@Test
public void testTopicProduceAndConsume_DurableSubscriber_Legacy() throws Exception {
String subscriptionId = GUID.safeUUID();
String clientId = GUID.safeUUID();
PasConsumer consumer = new PasConsumer().withTopic(getName());
consumer.setSubscriptionId(subscriptionId);
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
JmsConnection conn = activeMqBroker.getJmsConnection(createVendorImpl(), true);
conn.setClientId(clientId);
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(conn, consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
// Start it once to get some durable Action.
start(standaloneConsumer);
stop(standaloneConsumer);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl()), new PasProducer().withTopic(getName()));
int count = 10;
for (int i = 0; i < count; i++) {
ExampleServiceCase.execute(standaloneProducer, createMessage());
}
start(standaloneConsumer);
waitForMessages(jms, count);
assertMessages(jms, 10);
}
Aggregations