7

Suppose that I have many millions of events in a SQS queue and I want to get rid of them quickly, but I cannot just delete the queue and make a new one.

What is the fastest way to delete/drain those events out of the queue?

Arafat Nalkhande
  • 11,078
  • 9
  • 39
  • 63
Desmond Zhou
  • 1,369
  • 1
  • 11
  • 18

1 Answers1

9

I'm assuming that you don't care about the values in the messages, since you appear to want to drain it rather than process it. You can set the MessageRetentionPeriod to a very low value, and then drain any remaining messages out of the queue. After its drained, set the MessageRetentionPeriod back up to the desired value. You'll lose any messages that are older than the MessageRetentionPeriod.

Kent Murra
  • 234
  • 1
  • 2
  • That is a great idea, letting them expire on the server side. – Desmond Zhou Oct 25 '11 at 18:20
  • It took a bit of time for the server to drain the older messages when I did this trick. I'd say give it about 10 minutes. – Kent Murra Oct 25 '11 at 18:34
  • "Value must be between 1 minute and 14 days." I set mine to 1 minute and needed to wait maybe 10 minutes for messages to finally disappear from https://console.aws.amazon.com/sqs/home?region=us-east-1 It's a great trick! Thanks! See also http://stackoverflow.com/a/15488880/470749 – Ryan Jun 30 '14 at 20:45