_logger.warn("No message found, unable to DLQ delivery tag: " + deliveryTag);
return;
}
else
{
final ServerMessage msg = rejectedQueueEntry.getMessage();
final AMQQueue queue = rejectedQueueEntry.getQueue();
final Exchange altExchange = queue.getAlternateExchange();
unackedMap.remove(deliveryTag);
if (altExchange == null)
{
_logger.debug("No alternate exchange configured for queue, must discard the message as unable to DLQ: delivery tag: " + deliveryTag);
_actor.message(_logSubject, ChannelMessages.DISCARDMSG_NOALTEXCH(msg.getMessageNumber(), queue.getName(), msg.getRoutingKey()));
rejectedQueueEntry.discard();
return;
}
final InboundMessage m = new InboundMessageAdapter(rejectedQueueEntry);
final List<? extends BaseQueue> destinationQueues = altExchange.route(m);
if (destinationQueues == null || destinationQueues.isEmpty())
{
_logger.debug("Routing process provided no queues to enqueue the message on, must discard message as unable to DLQ: delivery tag: " + deliveryTag);
_actor.message(_logSubject, ChannelMessages.DISCARDMSG_NOROUTE(msg.getMessageNumber(), altExchange.getName()));
rejectedQueueEntry.discard();
return;
}
rejectedQueueEntry.routeToAlternate();
//output operational logging for each delivery post commit
for (final BaseQueue destinationQueue : destinationQueues)
{
_actor.message(_logSubject, ChannelMessages.DEADLETTERMSG(msg.getMessageNumber(), destinationQueue.getName()));
}
}
}