Search in sources :

Example 1 with ActiveJmsConnectionErrorHandler

use of com.adaptris.core.jms.ActiveJmsConnectionErrorHandler in project interlok by adaptris.

the class ActiveJmsConnectionErrorHandlerTest method createErrorHandler.

private ActiveJmsConnectionErrorHandler createErrorHandler() {
    ActiveJmsConnectionErrorHandler handler = new ActiveJmsConnectionErrorHandler();
    handler.setAdditionalLogging(true);
    handler.setCheckInterval(new TimeInterval(500L, TimeUnit.MILLISECONDS));
    return handler;
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) ActiveJmsConnectionErrorHandler(com.adaptris.core.jms.ActiveJmsConnectionErrorHandler)

Example 2 with ActiveJmsConnectionErrorHandler

use of com.adaptris.core.jms.ActiveJmsConnectionErrorHandler in project interlok by adaptris.

the class ActiveJmsConnectionErrorHandlerTest method testConnectionErrorHandlerWhileConnectionIsClosed.

@Test
public void testConnectionErrorHandlerWhileConnectionIsClosed() throws Exception {
    String queueName = testName.getMethodName() + "_queue";
    String topicName = testName.getMethodName() + "_topic";
    JmsConnection jmsCon = activeMqBroker.getJndiPasConnection(new StandardJndiImplementation(), false, queueName, topicName);
    jmsCon.setConnectionAttempts(null);
    MockChannel channel = createChannel(activeMqBroker, jmsCon, topicName);
    try {
        ActiveJmsConnectionErrorHandler handler = new ActiveJmsConnectionErrorHandler();
        handler.setCheckInterval(new TimeInterval(100L, TimeUnit.MILLISECONDS));
        handler.setAdditionalLogging(Boolean.TRUE);
        channel.getConsumeConnection().setConnectionErrorHandler(handler);
        channel.requestStart();
        assertEquals(StartedState.getInstance(), channel.retrieveComponentState());
        channel.requestClose();
        activeMqBroker.stop();
        activeMqBroker.start();
        assertEquals(ClosedState.getInstance(), channel.retrieveComponentState());
    } finally {
        channel.requestClose();
    }
}
Also used : MockChannel(com.adaptris.core.stubs.MockChannel) TimeInterval(com.adaptris.util.TimeInterval) StandardJndiImplementation(com.adaptris.core.jms.jndi.StandardJndiImplementation) JmsConnection(com.adaptris.core.jms.JmsConnection) ActiveJmsConnectionErrorHandler(com.adaptris.core.jms.ActiveJmsConnectionErrorHandler) Test(org.junit.Test)

Example 3 with ActiveJmsConnectionErrorHandler

use of com.adaptris.core.jms.ActiveJmsConnectionErrorHandler in project interlok by adaptris.

the class ActiveJmsConnectionErrorHandlerCase method testAdditionalLogging.

@Test
public void testAdditionalLogging() {
    ActiveJmsConnectionErrorHandler ajceh = new ActiveJmsConnectionErrorHandler();
    assertNull(ajceh.getAdditionalLogging());
    assertFalse(ajceh.additionalLogging());
    ajceh.setAdditionalLogging(Boolean.TRUE);
    assertNotNull(ajceh.getAdditionalLogging());
    assertEquals(true, ajceh.additionalLogging());
    assertEquals(Boolean.TRUE, ajceh.getAdditionalLogging());
    ajceh.setAdditionalLogging(null);
    assertNull(ajceh.getAdditionalLogging());
    assertFalse(ajceh.additionalLogging());
}
Also used : ActiveJmsConnectionErrorHandler(com.adaptris.core.jms.ActiveJmsConnectionErrorHandler) Test(org.junit.Test)

Example 4 with ActiveJmsConnectionErrorHandler

use of com.adaptris.core.jms.ActiveJmsConnectionErrorHandler in project interlok by adaptris.

the class ActiveJmsConnectionErrorHandlerCase method testRetryInterval.

@Test
public void testRetryInterval() {
    ActiveJmsConnectionErrorHandler handler = new ActiveJmsConnectionErrorHandler();
    assertNull(handler.getCheckInterval());
    assertEquals(5000, handler.retryInterval());
    TimeInterval interval = new TimeInterval(1L, TimeUnit.MINUTES);
    TimeInterval bad = new TimeInterval(0L, TimeUnit.MILLISECONDS);
    handler.setCheckInterval(interval);
    assertEquals(interval, handler.getCheckInterval());
    assertEquals(interval.toMilliseconds(), handler.retryInterval());
    handler.setCheckInterval(bad);
    assertEquals(bad, handler.getCheckInterval());
    assertEquals(5000, handler.retryInterval());
    handler.setCheckInterval(null);
    assertNull(handler.getCheckInterval());
    assertEquals(5000, handler.retryInterval());
}
Also used : TimeInterval(com.adaptris.util.TimeInterval) ActiveJmsConnectionErrorHandler(com.adaptris.core.jms.ActiveJmsConnectionErrorHandler) Test(org.junit.Test)

Aggregations

ActiveJmsConnectionErrorHandler (com.adaptris.core.jms.ActiveJmsConnectionErrorHandler)4 TimeInterval (com.adaptris.util.TimeInterval)3 Test (org.junit.Test)3 JmsConnection (com.adaptris.core.jms.JmsConnection)1 StandardJndiImplementation (com.adaptris.core.jms.jndi.StandardJndiImplementation)1 MockChannel (com.adaptris.core.stubs.MockChannel)1