From 574c76224e4bd16756b0fc5dcf426643e57616a5 Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Wed, 30 May 2012 10:43:35 -0400 Subject: [PATCH] AMQP-239 DLE/DLQ Documentation Describe how to invoke Dead Letter Exchange/Dead Letter Queue routing when rejecting messages in a listener container. --- src/docbkx/amqp.xml | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/src/docbkx/amqp.xml b/src/docbkx/amqp.xml index c2898280..1c893a45 100644 --- a/src/docbkx/amqp.xml +++ b/src/docbkx/amqp.xml @@ -1316,6 +1316,14 @@ public RabbitTransactionManager rabbitTransactionManager() { for any referenced 'listener' that is a POJO. Default is a SimpleMessageConverter. + + + requeueRejected + + Determines whether messages that are + rejected because the listener + threw an exception should be requeued or not. Default 'true'. + @@ -1419,16 +1427,37 @@ public RabbitTransactionManager rabbitTransactionManager() { Business exception handling, as opposed to protocol errors and dropped connections, might need more thought and some custom configuration, especially if transactions and/or container acks - are in use. AMQP has no definition of dead letter behaviour, so + are in use. Prior to 2.8.x, RabbitMQ had no definition of dead letter behaviour, so by default a message that is rejected or rolled back because of a business exception can be redelivered ad infinitum. To put a - limit in the client on the number of re-deliveries your best + limit in the client on the number of re-deliveries, one choice is a StatefulRetryOperationsInterceptor in the advice chain of the listener. The interceptor can have a recovery callback that implements a custom dead letter action: whatever is appropriate for your particular environment. + Another alternative is to set the container's rejectRequeued + property to false. This causes all failed messages to be discarded. + When using RabbitMQ 2.8.x or higher, this also facilitates + delivering the message to a Dead Letter Exchange. + + Or, you can throw a AmqpRejectAndDontRequeueException; + this prevents message requeuing, regardless of the setting of the + rejectRequeued property. + + Often, a combination of both techniques will be used. Use a + StatefulRetryOperationsInterceptor in the + advice chain, where it's MessageRecover + throws an AmqpRejectAndDontRequeueException. + The MessageRecover is called when all + retries have been exhausted. The default + MessageRecoverer simply consumes the + errant message and emits a WARN message. In which case, + the message is ACK'd and won't be sent to the Dead Letter + Exchange, if any. + +