use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class BasicJmsProducerCase method testTimedInactivitySession.
@Test
public void testTimedInactivitySession() throws Exception {
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
DefinedJmsProducer producer = createProducer(getName());
TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory(new TimeInterval(10L, TimeUnit.MILLISECONDS));
producer.setSessionFactory(psf);
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
Thread.sleep(200);
assertTrue(psf.newSessionRequired());
// Should create a new Session now.
standaloneProducer.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class BasicJmsProducerCase method testMessageSizeSession.
@Test
public void testMessageSizeSession() throws Exception {
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
DefinedJmsProducer producer = createProducer(getName());
MessageSizeProducerSessionFactory psf = new MessageSizeProducerSessionFactory(Integer.valueOf(DEFAULT_PAYLOAD.length() - 1).longValue());
producer.setSessionFactory(psf);
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
standaloneProducer.doService(createMessage());
assertTrue(psf.newSessionRequired());
// Should create a new Session now.
standaloneProducer.doService(createMessage());
waitForMessages(jms, 3);
assertMessages(jms, 3);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class BasicJmsProducerCase method testMessageCountSession_SessionStillValid.
@Test
public void testMessageCountSession_SessionStillValid() throws Exception {
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
DefinedJmsProducer producer = createProducer(getName());
MessageCountProducerSessionFactory psf = new MessageCountProducerSessionFactory();
producer.setSessionFactory(psf);
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
assertFalse(psf.newSessionRequired());
standaloneProducer.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class BasicPtpConsumerActiveErorHandlerTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
JmsConnection p = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
ActiveJmsConnectionErrorHandler erHandler = new ActiveJmsConnectionErrorHandler();
erHandler.setCheckInterval(new TimeInterval(30L, TimeUnit.SECONDS));
p.setConnectionErrorHandler(erHandler);
return new StandaloneConsumer(p, new PtpConsumer().withQueue("TheQueueToConsumeFrom"));
}
use of com.adaptris.core.StandaloneConsumer 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);
}
}
Aggregations