if(_logger.isDebugEnabled())
{
_logger.debug("RECV[" + _channelId + "] BasicReject[" +" deliveryTag: " + deliveryTag + " requeue: " + requeue + " ]");
}
MessageInstance message = getUnacknowledgedMessageMap().get(deliveryTag);
if (message == null)
{
_logger.warn("Dropping reject request as message is null for tag:" + deliveryTag);
}
else
{
if (message.getMessage() == null)
{
_logger.warn("Message has already been purged, unable to Reject.");
}
else
{
if (_logger.isDebugEnabled())
{
_logger.debug("Rejecting: DT:" + deliveryTag
+ "-" + message.getMessage() +
": Requeue:" + requeue
+
" on channel:" + debugIdentity());
}
if (requeue)
{
message.decrementDeliveryCount();
requeue(deliveryTag);
}
else
{
// Since the Java client abuses the reject flag for requeing after rollback, we won't set reject here
// as it would prevent redelivery
// message.reject();
final boolean maxDeliveryCountEnabled = isMaxDeliveryCountEnabled(deliveryTag);
_logger.debug("maxDeliveryCountEnabled: "
+ maxDeliveryCountEnabled
+ " deliveryTag "
+ deliveryTag);
if (maxDeliveryCountEnabled)
{
final boolean deliveredTooManyTimes = isDeliveredTooManyTimes(deliveryTag);
_logger.debug("deliveredTooManyTimes: "
+ deliveredTooManyTimes
+ " deliveryTag "
+ deliveryTag);
if (deliveredTooManyTimes)
{
deadLetter(deliveryTag);
}
else
{
//this requeue represents a message rejected because of a recover/rollback that we
//are not ready to DLQ. We rely on the reject command to resend from the unacked map
//and therefore need to increment the delivery counter so we cancel out the effect
//of the AMQChannel#resend() decrement.
message.incrementDeliveryCount();
}
}
else
{
requeue(deliveryTag);