public boolean callback(final long deliveryTag, QueueEntry message) throws AMQException { message.setRedelivered(); final Subscription subscription = message.getDeliveredSubscription(); if (subscription != null) { // Consumer exists if (!subscription.isClosed()) { _msgToResend.put(deliveryTag, message); } else // consumer has gone { _msgToRequeue.put(deliveryTag, message); } } else { // Message has no consumer tag, so was "delivered" to a GET // or consumer no longer registered // cannot resend, so re-queue. if (!message.isQueueDeleted()) { if (_requeueIfUnabletoResend) { _msgToRequeue.put(deliveryTag, message); } else { dequeueEntry(message); _log.info("No DeadLetter Queue and requeue not requested so dropping message:" + message); } } else { dequeueEntry(message); _log.warn("Message.queue is null and no DeadLetter Queue so dropping message:" + message); } } // false means continue processing return false; }
private void dequeueEntry(final QueueEntry node, ServerTransaction txn) { txn.dequeue( node.getQueue(), node.getMessage(), new ServerTransaction.Action() { public void postCommit() { node.discard(); } public void onRollback() {} }); }