Search in sources :

Example 1 with NonBlockingChannelStartStrategy

use of com.adaptris.core.lifecycle.NonBlockingChannelStartStrategy in project interlok by adaptris.

the class BasicActiveMqConsumerTest method testStartWithDurableSubscribers_WithNonBlockingChannelStrategy.

@Test
public void testStartWithDurableSubscribers_WithNonBlockingChannelStrategy() throws Exception {
    Adapter adapter = createDurableSubsAdapter(getName(), activeMqBroker);
    adapter.requestStart();
    assertEquals(StartedState.getInstance(), adapter.retrieveComponentState());
    adapter.requestClose();
    assertEquals(ClosedState.getInstance(), adapter.retrieveComponentState());
    adapter.getChannelList().setLifecycleStrategy(new NonBlockingChannelStartStrategy());
    adapter.requestStart();
    // Thread.sleep(1000);
    Channel c = adapter.getChannelList().getChannel(0);
    int maxAttempts = 100;
    int attempts = 0;
    while (attempts < maxAttempts && c.retrieveComponentState() != StartedState.getInstance()) {
        Thread.sleep(500);
        attempts++;
    }
    assertEquals(StartedState.getInstance(), c.retrieveComponentState());
    adapter.requestClose();
}
Also used : NonBlockingChannelStartStrategy(com.adaptris.core.lifecycle.NonBlockingChannelStartStrategy) MockChannel(com.adaptris.core.stubs.MockChannel) Channel(com.adaptris.core.Channel) Adapter(com.adaptris.core.Adapter) Test(org.junit.Test)

Aggregations

Adapter (com.adaptris.core.Adapter)1 Channel (com.adaptris.core.Channel)1 NonBlockingChannelStartStrategy (com.adaptris.core.lifecycle.NonBlockingChannelStartStrategy)1 MockChannel (com.adaptris.core.stubs.MockChannel)1 Test (org.junit.Test)1