Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Release a message back to SQS

Tags:

I have a some EC2 servers pulling work off of a SQS queue. Occasionally, they encounter a situation where the can't finish the job. I have the process email me of the condition. As it stands now, the message stays "in flight" until it times out. I would like for the process to immediately release it back to the queue after the email is sent. But, I'm not sure how to accomplish this. Is there a way? If so, can you please point me to the call or post a code snippet.

I'm using Python 2.7.3 and Boto 2.5.2.

like image 481
David S Avatar asked Jan 18 '13 17:01

David S


People also ask

How do I publish a message to SQS?

To send a message (console)Open the Amazon SQS console at https://console.aws.amazon.com/sqs/ . In the navigation pane, choose Queues. On the Queues page, choose a queue. Choose Send and receive messages.

How do you flush SQS messages?

To purge a queue, log in to the AWS Management Console and choose Amazon SQS. Then, select a queue, and choose “Purge Queue” from the Queue Actions menu. The queue will then be cleared of all messages. You can also purge queues using the AWS SDKs or command-line tools.

Can SQS replay messages?

Each time the SQS dead-letter queue receives a message, it triggers Lambda to run the replay function. The replay code uses an SQS message attribute `sqs-dlq-replay-nb` as a persistent counter for the current number of retries attempted.

Why are messages stuck in SQS?

It sounds like a worker is failing to correctly process the messages from the queue. When a worker (or app) retrieves a message from the queue, it needs to call DeleteMessage() when it has finished processing. This removes it from the queue.


1 Answers

If you have read a message and decide, for whatever reason, that you do not want to process it and would rather make it immediately available to other readers of the queue, you can simply set that message's visibility timeout to zero using the change_visibility method of the Message object in boto. See The SQS Developer's Guide for details.

like image 174
garnaat Avatar answered Sep 30 '22 01:09

garnaat