2
votes

I want to process messages from an Amazon SQS Dead Letter Queue.

What is the best way to process them?

  1. Receive messages from dead letter queue and process it.
  2. Receive messages from dead letter queue put back in main queue and then process it?

I just need to process messages from dead letter queue once in a while.

2

2 Answers

2
votes

Presumably the message ended up in the Dead Letter Queue for a reason, after failing several times.

It would not be a good idea to put it back in the main queue because, presumably, it would fail again and you would create an infinite loop.

Initially, dead messages should be examined manually to determine the causes of failure. Then, based on this information, an alternate flow could be developed.

1
votes

After careful consideration of various options, I am going with the option 2 "Receive messages from dead letter queue put back in main queue and then process it" you mentioned.

Make sure that while transferring the messages from one queue messages are not lost.

Before putting messages from DLQ to main queue, make sure that the errors faced in the main listener (mainly coding errors if any) are resolved or if any network issues are resolved.

The listener of the main queue has retried the message already and retrying it again. So please make sure to either skip already successful steps of message processing in case message is being retried. Also revert successfully processed steps in case of any errors. (This will will help in the message retry as well.)

DLQ is meant for unexpected errors. So you may have an on-demand job for doing this.