use of org.motechproject.event.domain.BuggyListener in project motech by motech.
the class ServerEventRelayBundleIT method shouldTriggerAllListenersIfOneListenerFailsWhenRelyingTopicEvent.
@Test
public void shouldTriggerAllListenersIfOneListenerFailsWhenRelyingTopicEvent() throws InterruptedException {
TrackingListener buggyListener = new BuggyListener(1);
TrackingListener firstGoodListener = new TrackingListener("first");
TrackingListener secondGoodListener = new TrackingListener("second");
eventListenerRegistry.registerListener(buggyListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(firstGoodListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(secondGoodListener, EXCEPTION_HANDLING_TEST);
MotechEvent testMessage = new MotechEvent(EXCEPTION_HANDLING_TEST);
eventRelay.broadcastEventMessage(testMessage);
while (buggyListener.getCount() < 2) {
Thread.sleep(1000);
}
Thread.sleep(2000);
assertEquals(firstGoodListener.getCount(), 1);
assertEquals(secondGoodListener.getCount(), 1);
}
use of org.motechproject.event.domain.BuggyListener in project motech by motech.
the class ServerEventRelayBundleIT method shouldNotTriggerAllListenersWhenOneListenerFails.
@Test
public void shouldNotTriggerAllListenersWhenOneListenerFails() throws InterruptedException {
TrackingListener buggyListener = new BuggyListener(1);
TrackingListener firstGoodListener = new TrackingListener("first");
TrackingListener secondGoodListener = new TrackingListener("second");
eventListenerRegistry.registerListener(buggyListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(firstGoodListener, EXCEPTION_HANDLING_TEST);
eventListenerRegistry.registerListener(secondGoodListener, EXCEPTION_HANDLING_TEST);
MotechEvent testMessage = new MotechEvent(EXCEPTION_HANDLING_TEST);
eventRelay.sendEventMessage(testMessage);
while (buggyListener.getCount() < 2) {
Thread.sleep(3000);
}
assertTrue(buggyListener.getCount() > 1);
Thread.sleep(2000);
assertEquals(1, firstGoodListener.getCount());
assertEquals(1, secondGoodListener.getCount());
}
use of org.motechproject.event.domain.BuggyListener in project motech by motech.
the class ServerEventRelayTest method shouldPreserveEventDestinationIfListenerFails.
@Test
public void shouldPreserveEventDestinationIfListenerFails() {
when(motechEventConfig.getMessageMaxRedeliveryCount()).thenReturn(2);
BuggyListener buggyListener = new BuggyListener(1);
setUpListeners(SUBJECT, buggyListener);
MotechEvent event = createEvent(buggyListener.getIdentifier());
eventRelay.relayQueueEvent(event);
assertThat(event.getMessageDestination().toString(), is(buggyListener.getIdentifier()));
}
Aggregations