use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmsConsumerTest method testQueueConsume.
@Test
public void testQueueConsume() throws Exception {
Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
String rfc6167 = "jms:queue:" + getName();
JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer producer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
// INTERLOK-3329 For coverage so the prepare() warning is executed 2x
LifecycleHelper.prepare(standaloneConsumer);
LifecycleHelper.prepare(producer);
execute(standaloneConsumer, producer, createMessage(null), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmsConsumerTest method retrieveObjectsForSampleConfig.
@Override
protected List<?> retrieveObjectsForSampleConfig() {
ArrayList<StandaloneConsumer> result = new ArrayList<>();
boolean useQueue = true;
for (MessageTypeTranslator t : MESSAGE_TRANSLATOR_LIST) {
StandaloneConsumer p = retrieveSampleConfig(useQueue);
((JmsConsumerImpl) p.getConsumer()).setMessageTranslator(t);
result.add(p);
useQueue = !useQueue;
}
return result;
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmsConsumerTest method testTopicConsume.
@Test
public void testTopicConsume() throws Exception {
Assume.assumeTrue(JmsConfig.jmsTestsEnabled());
String rfc6167 = "jms:topic:" + getName();
JmsConsumer consumer = new JmsConsumer().withEndpoint(rfc6167);
;
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), new JmsProducer().withEndpoint(rfc6167));
execute(standaloneConsumer, standaloneProducer, createMessage(null), jms);
assertMessages(jms, 1);
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmsConsumerTest method retrieveSampleConfig.
protected StandaloneConsumer retrieveSampleConfig(boolean destQueue) {
JmsConnection c = new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:61616"));
String dest = "jms:topic:MyTopicName?subscriptionId=mySubscriptionId";
if (destQueue) {
dest = "jms:queue:MyQueueName";
}
JmsConsumer pc = new JmsConsumer().withEndpoint(dest);
c.setConnectionErrorHandler(new JmsConnectionErrorHandler());
StandaloneConsumer result = new StandaloneConsumer(c, pc);
return result;
}
use of com.adaptris.core.StandaloneConsumer in project interlok by adaptris.
the class JmsProducerTest method testTimedInactivitySession_SessionStillValid.
@Test
public void testTimedInactivitySession_SessionStillValid() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "";
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
JmsProducer producer = createProducer(rfc6167);
TimedInactivityProducerSessionFactory psf = new TimedInactivityProducerSessionFactory();
producer.setSessionFactory(psf);
standaloneConsumer.registerAdaptrisMessageListener(jms);
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
Thread.sleep(200);
assertFalse(psf.newSessionRequired());
// Still should be a valid session; and could produce regardless.
standaloneProducer.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
Aggregations