//might get changed after the client has sent the cancel - and we don't want to end up cancelling
//back to the original queue
boolean reachedMaxDeliveryAttempts =
cancel.isReachedMaxDeliveryAttempts() || cancel.getDeliveryCount() >= rec.maxDeliveryAttempts;
Delivery del = rec.del;
if (!expired && !reachedMaxDeliveryAttempts)
{
//Normal cancel back to the queue
del.getReference().setDeliveryCount(cancel.getDeliveryCount());
//Do we need to set a redelivery delay?
if (rec.redeliveryDelay != 0)
{
del.getReference().setScheduledDeliveryTime(System.currentTimeMillis() + rec.redeliveryDelay);
}
if (trace) { log.trace("Cancelling delivery " + cancel.getDeliveryId()); }
del.cancel();
}
else
{
if (expired)
{
//Sent to expiry queue
JBossMessage copy = makeCopyForDLQOrExpiry(true, del);
moveInTransaction(copy, del, rec.expiryQueue, false);
}
else
{
//Send to DLQ
JBossMessage copy = makeCopyForDLQOrExpiry(false, del);
moveInTransaction(copy, del, rec.dlq, true);
}
}
//Need to send a message to the replicant to remove the id
postOffice.sendReplicateAckMessage(rec.queueName, del.getReference().getMessage().getMessageID());
return rec.del;
}