0

Is there any functionality built in to spring-amqp that would make it easy to requeue dead letter messages? I can write code to do it but it seems like such a common use case that would fit well into the framework.

Josh Chappelle
  • 1,558
  • 2
  • 15
  • 37
  • Can you be more detail than in your below comment ? Is there exists a way to set a limit for requeuing some message ? I mean something like that: Give three chances for requeuing for each message. After three messages reject it. –  Mar 23 '17 at 15:24

1 Answers1

1

This is outside of Spring AMQP, but you can configure a TTL on the dead letter queue and configure that queue to dead-letter back to the original queue when expired.

You can check the x-death header if you want to give up completely after some number of retry cycles.

See this answer and its question for more information.

Community
  • 1
  • 1
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Gary this works great. We hit something today as a result of implementing this that I thought I would share for your future reference. We had a case in our dev environment where a MessageListener was erroring out over and over. We eventually started seeing errors in RabbitMQ of frame_too_large. After researching we found in the RabbitMQ documentation that an array gets added to the x-death header you mentioned each time a message is dead lettered. Since our solution sets up an endless cycle the message got too large and it eventually blew up. Future readers might want to consider a max retry. – Josh Chappelle Jan 20 '16 at 18:39
  • @JoshChappelle with newer versions of the broker, the `x-death` header contains only one entry per queue visited and updates a count each time, instead of extending the header on each round. – Gary Russell Mar 25 '17 at 16:16
  • Yep we have upgraded our broker and no longer have that problem. Thanks for mentioning that. – Josh Chappelle Mar 25 '17 at 17:29