Rachel
Rachel

Reputation: 1

How to keep SQS message alive when it fails?

I am using SQS to hold http requests. How can I keep the message alive (in the queue) to be re-processed when the request fails, without another process grabbing it?

Upvotes: 0

Views: 464

Answers (1)

John Rotenstein
John Rotenstein

Reputation: 270144

The typical process is:

  • A message is placed into the Amazon SQS queue
  • A worker process calls ReceiveMessage() to retrieve a message from the queue
  • The message is temporarily marked as 'invisible' (in-flight) so that other workers cannot see the message
  • If the worker successfully processes the message, it calls DeleteMessage() to permanently remove the message
  • If the worker does not respond within the Invisibility Timeout period (eg if it fails), the message will reappear on the queue. The message can then be grabbed by another worker.
  • If a Dead Letter Queue has been configured, then a message that is retrieved from the queue more than a defined number of times will be moved to the Dead Letter Queue for separate investigation or re-processing.

Your question seems to fit the scenario for using a Dead Letter Queue.

Upvotes: 4

Related Questions