use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class FailoverPtpProducerTest method testBug845.
@Test
public void testBug845() throws Exception {
Object input = retrieveObjectForSampleConfig();
String xml = defaultMarshaller.marshal(input);
StandaloneProducer output = (StandaloneProducer) defaultMarshaller.unmarshal(xml);
FailoverJmsConnection unmarshalled = (FailoverJmsConnection) output.getConnection();
assertEquals("Connection count == 2", 2, unmarshalled.getConnections().size());
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicJmsProducerCase method testProducerSession_Invalided.
// INTERLOK-2121
@Test
public void testProducerSession_Invalided() throws Exception {
DefinedJmsProducer producer = createProducer(getName());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneProducer);
AdaptrisMessage msg = createMessage();
standaloneProducer.doService(msg);
assertNotNull(producer.producerSession());
stop(standaloneProducer);
assertNull(producer.producerSession());
} finally {
stop(standaloneProducer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicJmsProducerCase method testPerMessageSession.
@Test
public void testPerMessageSession() throws Exception {
JmsConsumerImpl consumer = createConsumer(getName());
consumer.setAcknowledgeMode("AUTO_ACKNOWLEDGE");
StandaloneConsumer standaloneConsumer = new StandaloneConsumer(activeMqBroker.getJmsConnection(), consumer);
MockMessageListener jms = new MockMessageListener();
standaloneConsumer.registerAdaptrisMessageListener(jms);
DefinedJmsProducer producer = createProducer(getName());
producer.setSessionFactory(new PerMessageProducerSessionFactory());
StandaloneProducer standaloneProducer = new StandaloneProducer(activeMqBroker.getJmsConnection(), producer);
try {
start(standaloneConsumer, standaloneProducer);
standaloneProducer.doService(createMessage());
// Should create a new Session now.
standaloneProducer.doService(createMessage());
waitForMessages(jms, 2);
assertMessages(jms, 2);
} finally {
stop(standaloneProducer, standaloneConsumer);
}
}
use of com.adaptris.core.StandaloneProducer in project interlok by adaptris.
the class BasicJmsProducerCase method testMessageCountSession.
@Test
public void testMessageCountSession() 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(1);
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.StandaloneProducer 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);
}
}
Aggregations