use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class FailoverJdbcConnectionTest method configure.
@Override
protected FailoverJdbcConnection configure(FailoverJdbcConnection conn1) throws Exception {
String url = initialiseDatabase();
conn1.addConnectUrl(url);
conn1.setDriverImp(DRIVER_IMP);
conn1.setDebugMode(true);
conn1.setConnectionAttempts(1);
conn1.setConnectionRetryInterval(new TimeInterval(10L, TimeUnit.MILLISECONDS.name()));
conn1.setAlwaysValidateConnection(true);
return conn1;
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class AggregatingJmsConsumeServiceTest method createService.
private AggregatingJmsConsumeService createService(EmbeddedActiveMq broker, AggregatingQueueConsumer consumer, String queue) {
AggregatingJmsConsumeService result = new AggregatingJmsConsumeService();
result.setConnection(broker.getJmsConnection(new BasicActiveMqImplementation(), true));
consumer.setFilterExpression("%message{" + DEFAULT_FILTER_KEY + "}");
consumer.setEndpoint(queue);
consumer.setTimeout(new TimeInterval(5L, TimeUnit.SECONDS));
result.setJmsConsumer(consumer);
return result;
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class JmsProducerTest method testMultipleRequestorWithSession.
@Test
public void testMultipleRequestorWithSession() throws Exception {
String rfc6167 = "jms:queue:" + getName() + "";
ServiceList serviceList = new ServiceList(new Service[] { new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS)), new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS)) });
Loopback echo = createLoopback(activeMqBroker, getName());
try {
echo.start();
start(serviceList);
AdaptrisMessage msg1 = createMessage();
AdaptrisMessage msg2 = createMessage();
serviceList.doService(msg1);
serviceList.doService(msg2);
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg1.getContent());
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg2.getContent());
} finally {
stop(serviceList);
echo.stop();
}
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class JmsProducerTest method testRequest_DefinedReplyTo.
@Test
public void testRequest_DefinedReplyTo() throws Exception {
String rfc6167 = String.format("jms:queue:%1$s?replyToName=%1$s_reply", getName());
StandaloneRequestor serviceList = new StandaloneRequestor(activeMqBroker.getJmsConnection(), createProducer(rfc6167), new TimeInterval(1L, TimeUnit.SECONDS));
Loopback echo = createLoopback(activeMqBroker, getName());
try {
echo.start();
start(serviceList);
AdaptrisMessage msg = createMessage();
serviceList.doService(msg);
assertEquals(DEFAULT_PAYLOAD.toUpperCase(), msg.getContent());
} finally {
stop(serviceList);
echo.stop();
}
}
use of com.adaptris.util.TimeInterval in project interlok by adaptris.
the class FailoverJmsProducerCase method testEventuallyConnects.
@Test
public void testEventuallyConnects() throws Exception {
FailoverJmsConnection connection = new FailoverJmsConnection();
connection.addConnection(new JmsConnection(new BasicActiveMqImplementation("tcp://localhost:123456")));
connection.addConnection(activeMqBroker.getJmsConnection(new BasicActiveMqImplementation(), true));
connection.setConnectionRetryInterval(new TimeInterval(250L, TimeUnit.MILLISECONDS));
connection.addExceptionListener(new StandaloneConsumer());
connection.setRegisterOwner(true);
ScheduledExecutorService es = Executors.newSingleThreadScheduledExecutor();
try {
es.schedule(new Runnable() {
@Override
public void run() {
try {
activeMqBroker.start();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}, 2L, TimeUnit.SECONDS);
LifecycleHelper.initAndStart(connection);
} finally {
LifecycleHelper.stopAndClose(connection);
es.shutdownNow();
}
}
Aggregations