*
* @throws AMQException If something goes wrong.
*/
public void requeue(long deliveryTag) throws AMQException
{
UnacknowledgedMessage unacked = _unacknowledgedMessageMap.remove(deliveryTag);
if (unacked != null)
{
// Ensure message is released for redelivery
if (!unacked.isQueueDeleted())
{
unacked.entry.release();
}
// Mark message redelivered
unacked.getMessage().setRedelivered(true);
// Deliver these messages out of the transaction as their delivery was never
// part of the transaction only the receive.
TransactionalContext deliveryContext;
if (!(_txnContext instanceof NonTransactionalContext))
{
// if (_nonTransactedContext == null)
{
_nonTransactedContext =
new NonTransactionalContext(_messageStore, _storeContext, this, _returnMessages, _browsedAcks);
}
deliveryContext = _nonTransactedContext;
}
else
{
deliveryContext = _txnContext;
}
if (!unacked.isQueueDeleted())
{
// Redeliver the messages to the front of the queue
deliveryContext.deliver(unacked.entry, true);
// Deliver increments the message count but we have already deliverted this once so don't increment it again
// this was because deliver did an increment changed this.
}
else
{
_log.warn(System.identityHashCode(this) + " Requested requeue of message(" + unacked.getMessage().debugIdentity()
+ "):" + deliveryTag + " but no queue defined and no DeadLetter queue so DROPPING message.");
// _log.error("Requested requeue of message:" + deliveryTag +
// " but no queue defined using DeadLetter queue:" + getDeadLetterQueue());
//
// deliveryContext.deliver(unacked.message, getDeadLetterQueue(), false);