}
}
});
// enhance the counter callback to count, then throw an exception
final CounterCallback callback = new CounterCallback()
{
@Override
public void eventReceived(MuleEventContext context, Object Component) throws Exception
{
final int count = incCallbackCount();
logger.info("Message Delivery Count is: " + count);
throw new FunctionalTestException();
}
};
ftc.setEventCallback(callback);
client.dispatch(DESTINATION, TEST_MESSAGE, null);
Thread.sleep(2000);
mrexFired.await(timeout, TimeUnit.MILLISECONDS);
assertEquals("MessageRedeliveredException never fired.", 0, mrexFired.getCount());
assertEquals("Wrong number of delivery attempts", MAX_REDELIVERY + 1, callback.getCallbackCount());
MuleMessage dl = client.request("jms://dead.letter", 1000);
assertNotNull(dl);
assertTrue(dl.getPayload() instanceof ExceptionMessage);
ExceptionMessage em = (ExceptionMessage) dl.getPayload();