GridDragon
GridDragon

Reputation: 3145

Move SQS Message To Different Queue

Is there a way to move a message from one queue to another? We have a case where messages may end up in the DLQ due to a resource not being available. Once the issue is resolved we'd like to move the message back to the original queue and have it processed again. For our tracking purposes it'd be nice if the original MessageId and SentTimestamp are preserved.

The closest thing I've found is creating a new SendMessageRequest object and copying the contents of the message over. But this will create a brand new message with a new ID and timestamp.

When a message is moved the DLQ the id and timestamp is preserved. Isn't it possible to just reverse this action somehow?

Upvotes: 3

Views: 3138

Answers (1)

Mircea
Mircea

Reputation: 10566

No. You cannot preserve the message id when moving between queues. SQS gives you the id and the timestamp:

http://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/ImportantIdentifiers.html

What you can do is in your application you either:

  • have the ability to pick from both queues (and in normal operation mode you just have the normal queue). you enable the DLQ when reprocessing
  • you stamp the messageid and the timestamp in the message body when you requeue and in your application you first look in the message body before looking at the message itself. (you still need to use the sqs assigned messageid to ack the processing though)

Upvotes: 3

Related Questions