Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SQS: Moving to dead letter queue when error happens in consumer

I have tried using npm packages like sqs-queue-parallel & sqs-consumer for consuming messages of SQS in node

But lately I have mechanism where when error happens for a particular message while processing, it should be moved to dead letter queue

But as of now it keeps on retrying the message by maximum receive count times

Is it possible with some other npm package, were whenever an error happens it should be moved directly to dead letter queue?

like image 390
sarathprasath Avatar asked Apr 29 '16 02:04

sarathprasath


2 Answers

Know this is a bit late but think OP is trying to ask for a dynamic policy. I.e.:

  • on normal errors -> retry as per redrive-policy.
  • However, for certain failures you might know you can't recover even if you try it a hundred items. In that case -> move message directly to dead letter queue.

How to do the latter if presumably what is asked.

Answer is probably to manually copy message to deadletter queue (it behaves just like any other queue in that regard) and remove message from source queue afterwards.

Don't believe there's a 'special' way to do this.

like image 100
Geert-Jan Avatar answered Sep 27 '22 23:09

Geert-Jan


You can configure your SQS queue to move messages to your Dead Letter Queue after any number of failed message receives between 1 and 1000.

To have a message moved to the Dead Letter Queue after only one failed receive, then modify your queue's configuration and set the "Maximum Receives" value to 1. This would be part of your queue's "Redrive Policy".

See the following AWS documentation on configuring your queue: http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/SQSDeadLetterQueue.html

like image 32
Matt Houser Avatar answered Sep 27 '22 21:09

Matt Houser