Search in sources :

Example 31 with TimeInterval

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;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval)

Example 32 with TimeInterval

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;
}
Also used : BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval)

Example 33 with TimeInterval

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();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) TimeInterval(com.adaptris.util.TimeInterval) Loopback(com.adaptris.core.jms.BasicJmsProducerCase.Loopback) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Test(org.junit.Test)

Example 34 with TimeInterval

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();
    }
}
Also used : StandaloneRequestor(com.adaptris.core.StandaloneRequestor) TimeInterval(com.adaptris.util.TimeInterval) Loopback(com.adaptris.core.jms.BasicJmsProducerCase.Loopback) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 35 with TimeInterval

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();
    }
}
Also used : ScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) BasicActiveMqImplementation(com.adaptris.core.jms.activemq.BasicActiveMqImplementation) TimeInterval(com.adaptris.util.TimeInterval) StandaloneConsumer(com.adaptris.core.StandaloneConsumer) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Aggregations

TimeInterval (com.adaptris.util.TimeInterval)310 Test (org.junit.Test)249 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)86 StandaloneConsumer (com.adaptris.core.StandaloneConsumer)49 MockMessageListener (com.adaptris.core.stubs.MockMessageListener)42 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)40 FixedIntervalPoller (com.adaptris.core.FixedIntervalPoller)38 Channel (com.adaptris.core.Channel)36 MockChannel (com.adaptris.core.stubs.MockChannel)32 File (java.io.File)28 StandardWorkflow (com.adaptris.core.StandardWorkflow)27 Adapter (com.adaptris.core.Adapter)26 GuidGenerator (com.adaptris.util.GuidGenerator)25 FilenameFilter (java.io.FilenameFilter)24 Perl5FilenameFilter (org.apache.oro.io.Perl5FilenameFilter)24 StandaloneProducer (com.adaptris.core.StandaloneProducer)23 CoreException (com.adaptris.core.CoreException)22 WaitService (com.adaptris.core.services.WaitService)22 RandomAccessFile (java.io.RandomAccessFile)21 ObjectName (javax.management.ObjectName)21