Search code examples
architecturemessage-queuedead-letter

How to avoid a message landing in a dead letter queue?


How do I design an application such that the messages avoids the dead letter queue as much as possible.

As per wikipedia documentation below are the reasons that a message is sent to the dead letter queue

  • Message that is sent to a queue that does not exist.
  • Queue length limit exceeded.
  • Message length limit exceeded.
  • Message is rejected by another queue exchange.
  • Message reaches a threshold read counter number, because it is not consumed. Sometimes this is called a "back out queue".

We will be able to design the system avoiding the known reasons. But how to make the system to address the unknown scenarios. I am not looking for any vendor specific solution but a general design guideline or recommendations.


Solution

  • The answer is "You don't". over-engineering will only get you into trouble.

    Just accept the fact that a message will eventually fail and end up in a dead/poison queue and you need your monitoring systems to pick those messages up and notify the people who can investigate and resolve.

    You could design and implement functions in your monitoring back-end to allow your team to inspect, edit, and replay those messages.