Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS SQS Boto3 sending messages to dead letter manually

So I am building a small application that uses SQS. I have a simple handler process that determines if a given message is considered processed, marked for retry (to be re-queued) or is not able to be processed (should be sent to dead letter).

However based on the docs it would appear the only way to truly send a message to DL is by using a redrive policy which operates over # of receives a message has racked up. Because of the nature of my application, I could have several valid retries if my process isn't ready to handle a given message, but there are also times I may want to DL a message I have just received. Does AWS/Boto3 not provide a way to mark a specific message for DL?

I know I can just send the message myself to another queue I consider my own DL, I would just rather use AWS' built in tools for this.

like image 812
Turk Avatar asked May 01 '18 14:05

Turk


People also ask

Why does SQS messages go to DLQ?

If the consumer of the source queue receives a message 6, without successfully consuming it, SQS moves the message to the dead-letter queue. You can configure an alarm to alert you when any messages are delivered to a DLQ. You can then examine logs for exceptions that might have caused them to be delivered to the DLQ.

How do I send a delayed message with SQS?

To set delay seconds on individual messages, rather than on an entire queue, use message timers to allow Amazon SQS to use the message timer's DelaySeconds value instead of the delay queue's DelaySeconds value. To use the Amazon Web Services Documentation, Javascript must be enabled.


1 Answers

I don't believe there is any limitation that would prevent you from sending the message to the deal-letter-queue by yourself.

So just read the message from the Q, if you know it needs to go to the DLQ directly, send it to the DLQ and remove it from the regular Q.

like image 171
E.J. Brennan Avatar answered Nov 13 '22 22:11

E.J. Brennan