}
}
for (Map.Entry<Long, QueueEntry> entry : msgToResend.entrySet())
{
QueueEntry message = entry.getValue();
long deliveryTag = entry.getKey();
ServerMessage msg = message.getMessage();
AMQQueue queue = message.getQueue();
// Our Java Client will always suspend the channel when resending!
// If the client has requested the messages be resent then it is
// their responsibility to ensure that thay are capable of receiving them
// i.e. The channel hasn't been server side suspended.
// if (isSuspended())
// {
// _logger.info("Channel is suspended so requeuing");
// //move this message to requeue
// msgToRequeue.add(message);
// }
// else
// {
// release to allow it to be delivered
// 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();
_unacknowledgedMessageMap.remove(deliveryTag);
message.setRedelivered();
message.release();
}
}