use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class ActiveMqPasPollingConsumerTest method createStandalone.
private StandaloneConsumer createStandalone(EmbeddedActiveMq mq, String threadName, String destinationName) throws Exception {
PasPollingConsumer consumer = new PasPollingConsumer().withTopic(destinationName);
consumer.setPoller(new Sometime());
JmsConnection c = mq.getJmsConnection();
consumer.setVendorImplementation(c.getVendorImplementation());
consumer.setClientId(c.getClientId());
consumer.setSubscriptionId(MY_SUBSCRIPTION_ID);
consumer.setReacquireLockBetweenMessages(true);
consumer.setAdditionalDebug(true);
consumer.setReceiveTimeout(new TimeInterval(Integer.valueOf(new Random().nextInt(100) + 100).longValue(), TimeUnit.MILLISECONDS));
StandaloneConsumer sc = new StandaloneConsumer(consumer);
return sc;
}
use of com.adaptris.core.StandaloneConsumer 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.StandaloneConsumer in project interlok by adaptris.
the class AdvancedActiveMqConsumerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JmsConnection connection = new JmsConnection();
PtpConsumer producer = new PtpConsumer();
producer.setQueue("destination");
UrlVendorImplementation vendorImpl = createImpl();
vendorImpl.setBrokerUrl(BasicActiveMqImplementationTest.PRIMARY);
connection.setUserName("BrokerUsername");
connection.setPassword("BrokerPassword");
connection.setVendorImplementation(vendorImpl);
StandaloneConsumer result = new StandaloneConsumer();
result.setConnection(connection);
result.setConsumer(producer);
return result;
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class AdvancedActiveMqProducerTest method testQueueProduceAndConsumeWithPrefetch.
@Test
public void testQueueProduceAndConsumeWithPrefetch() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl(null, createPrefetch())), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl(null, createPrefetch())), new PtpProducer().withQueue((getName())));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class AdvancedActiveMqProducerTest method testQueueProduceAndConsumeWithRedeliveryPolicy.
@Test
public void testQueueProduceAndConsumeWithRedeliveryPolicy() throws Exception {
PtpConsumer consumer = new PtpConsumer().withQueue(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(createVendorImpl(createRedelivery(), null)), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(createVendorImpl(createRedelivery(), null)), new PtpProducer().withQueue((getName())));
execute(standaloneConsumer, standaloneProducer, createMessage(), jms);
assertMessages(jms, 1);
}
Aggregations