use of com.adaptris.util.TimeInterval 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.util.TimeInterval 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.util.TimeInterval in project interlok by adaptris.
the class EmbeddedActiveMq method applyCfg.
private JmsConnection applyCfg(JmsConnection con, BasicActiveMqImplementation impl, boolean useTcp) {
if (useTcp) {
impl.setBrokerUrl(DEF_URL_PREFIX + port);
} else {
impl.setBrokerUrl("vm://" + getName());
}
con.setClientId(createSafeUniqueId(impl));
con.setVendorImplementation(impl);
con.setConnectionRetryInterval(new TimeInterval(3L, TimeUnit.SECONDS));
con.setConnectionAttempts(1);
return con;
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method testHandleChannelUnavailable_Bug2343.
@Test
public void testHandleChannelUnavailable_Bug2343() throws Exception {
int msgCount = 10;
String destination = createSafeUniqueId(new Object());
final Channel channel = createStartableChannel(activeMqBroker, true, "testHandleChannelUnavailable_Bug2343", destination);
JmsTransactedWorkflow workflow = (JmsTransactedWorkflow) channel.getWorkflowList().get(0);
workflow.setChannelUnavailableWaitInterval(new TimeInterval(1L, TimeUnit.SECONDS));
try {
channel.requestStart();
channel.toggleAvailability(false);
Timer t = new Timer();
t.schedule(new TimerTask() {
@Override
public void run() {
channel.toggleAvailability(true);
}
}, 666);
StandaloneProducer sender = new StandaloneProducer(activeMqBroker.getJmsConnection(), new PtpProducer().withQueue((destination)));
send(sender, msgCount);
waitForMessages((MockMessageProducer) workflow.getProducer(), msgCount);
assertEquals(msgCount, ((MockMessageProducer) workflow.getProducer()).getMessages().size());
} finally {
channel.requestClose();
}
assertEquals(0, activeMqBroker.messagesOnQueue(destination));
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class ActiveMqJmsTransactedWorkflowTest method createWorkflow.
private JmsTransactedWorkflow createWorkflow(boolean isPtp, String threadName, String target) throws CoreException {
JmsTransactedWorkflow workflow = new JmsTransactedWorkflow();
workflow.setWaitPeriodAfterRollback(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
workflow.setProducer(new MockMessageProducer());
JmsConsumerImpl jmsCons = isPtp ? new PtpConsumer().withQueue(target) : new PasConsumer().withTopic(target);
jmsCons.setMessageTranslator(new TextMessageTranslator().withMoveJmsHeaders(true));
workflow.setConsumer(jmsCons);
return workflow;
}
Aggregations