}
}
for (Map.Entry<Long, QueueEntry> entry : msgToResend.entrySet())
{
QueueEntry message = entry.getValue();
long deliveryTag = entry.getKey();
//Amend the delivery counter as the client hasn't seen these messages yet.
message.decrementDeliveryCount();
AMQQueue queue = message.getQueue();
// Without any details from the client about what has been processed we have to mark
// all messages in the unacked map as redelivered.
message.setRedelivered();
Subscription sub = message.getDeliveredSubscription();
if (sub != null)
{
if(!queue.resend(message,sub))
{
msgToRequeue.put(deliveryTag, message);
}
}
else
{
if (_logger.isInfoEnabled())
{
_logger.info("DeliveredSubscription not recorded so just requeueing(" + message.toString()
+ ")to prevent loss");
}
// move this message to requeue
msgToRequeue.put(deliveryTag, message);
}
} // for all messages
// } else !isSuspend
if (_logger.isInfoEnabled())
{
if (!msgToRequeue.isEmpty())
{
_logger.info("Preparing (" + msgToRequeue.size() + ") message to requeue to.");
}
}
// Process Messages to Requeue at the front of the queue
for (Map.Entry<Long, QueueEntry> entry : msgToRequeue.entrySet())
{
QueueEntry message = entry.getValue();
long deliveryTag = entry.getKey();
//Amend the delivery counter as the client hasn't seen these messages yet.
message.decrementDeliveryCount();
_unacknowledgedMessageMap.remove(deliveryTag);
message.setRedelivered();
message.release();
}
}