// must decrement the redelivery counter as we didn't process the redelivery but is
// handling by the failure handler. So we must -1 to not let the counter be out-of-sync
decrementRedeliveryCounter(exchange);
AsyncProcessor afp = AsyncProcessorTypeConverter.convert(data.failureProcessor);
boolean sync = afp.process(exchange, new AsyncCallback() {
public void done(boolean sync) {
restoreExceptionOnExchange(exchange, data.handledPredicate);
callback.done(data.sync);
}
});
// The line below shouldn't be needed, it is invoked by the AsyncCallback above
//restoreExceptionOnExchange(exchange, data.handledPredicate);
logger.log("Failed delivery for exchangeId: " + exchange.getExchangeId() + ". Handled by the failure processor: " + data.failureProcessor);
return sync;
}
// should we redeliver
if (data.redeliveryCounter > 0) {
// okay we will give it another go so clear the exception so we can try again
if (exchange.getException() != null) {
exchange.setException(null);
}
// wait until we should redeliver
data.redeliveryDelay = data.currentRedeliveryPolicy.sleep(data.redeliveryDelay);
}
// process the exchange
boolean sync = outputAsync.process(exchange, new AsyncCallback() {
public void done(boolean sync) {
// Only handle the async case...
if (sync) {
return;
}