View Full Version : Dead Lettering
Apr 3rd, 2012, 05:30 AM
RabbitMQ 2.8 supports dead lettering, see http://www.rabbitmq.com/extensions.html#dead-letter-exchanges.
I use a StatefulRetryOperationsInterceptorFactoryBean and after x tries I want the message to go to the dead letter exchange. As far as I understand the message needs to be rejected after the retries. How can I do that?
Are there any plans for extended dead lettering support in Spring AMQP?
Apr 3rd, 2012, 06:56 AM
If you provide a MessageRecoverer to the factory bean (called when retries are exhausted), and it throws an exception, the listener will send a basic.reject which should trigger the DLQ behavior, according the the RabbitMQ docs.
DLQ configuration is controlled by queue arguments; spring-amqp supports this in a number of ways, such as...
<entry key="x-dead-letter-exchange" value="my.dlq.exchange" />
However, there have been some rabbit API changes and the 1.0.0.RELEASE doesn't support 2.8.0.
I do have a branch on my clone that supports the newer API https://github.com/garyrussell/spring-amqp/tree/AMQP-195 and I have tested it against 2.8.0 if you want to experiment with DLQs.
We expect to release this in 1.0.1 shortly.
Apr 3rd, 2012, 08:14 AM
Sorry - my mistake, I see we have to set requeue to false on the reject to invoke DLQ behavior.
Please open an improvement JIRA here...
Apr 3rd, 2012, 10:54 AM
I have pushed a prototype implementation here... https://github.com/garyrussell/spring-amqp/tree/dlq
As noted in the commit comment, there is currently a problem with dead-lettering messages sent to durable queues, but I have tested without issue with non-durable queues.
The Rabbit guys know about the problem and it will be fixed in an upcoming release.
May 15th, 2012, 07:58 AM
Thanks Gary! Any idea when the 1.0.1 release will be out?
May 15th, 2012, 08:16 AM
The release (now called 1.1.0.RELEASE) will be announced imminently, once we get the documentation up on the SpringSource web site; the jars should be in maven central already.
It uses spring-retry-1.0.1.RELEASE, which fixes a problem with the exponential back-off policy when you use the retry interceptor.
In order to send the message to the DLE/DLQ, the MessageRecoverer must throw an AmqpRejectAndDontRequeueException. This signals the listener container to reject the message, with requeue set to false, causing the message to be sent to the Dead Letter Exchange.
Update your POMs, and give it a shot!
For users not using retry, where you want to immediately send to the DLE/DLQ if one attempt fails, you can simply set requeue-rejected to false (defaults to true) on the container.
Powered by vBulletin® Version 4.2.1 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.