Delete All Messages in an Amazon SQS Queue

Posted on: Dec 8, 2014

Amazon Simple Queue Service (SQS) is a fast, reliable, scalable, fully managed message queuing service. You can use SQS to transmit any volume of data, at any level of throughput, without losing messages or requiring other services to be always available.

You can now delete all messages in an SQS queue using the new PurgeQueue action. When you purge a queue, all the messages previously sent to the queue will be deleted. Since your queue and its attributes will remain, there is no need to reconfigure the queue to continue using it.

For example, if you are developing an application, you can make changes to the message format without replacing the queue. When debugging an application, you can clear the queue to remove potentially erroneous messages. If you are testing your application, you can drive a high message volume through it and then purge it to start fresh before entering production.

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.

The message deletion process takes up to 60 seconds; messages sent to the queue during this time may be deleted. If you only need to delete specific messages, you can use the DeleteMessage or DeleteMessageBatch actions. To learn more about Amazon SQS, visit: http://aws.amazon.com/sqs/