Using Dead Letter Queues in Amazon SQS

Amazon SQS provides support for dead letter queues. A dead letter queue is a queue that other queues
can target for messages that can't be processed successfully. You can set aside and
isolate
these messages in the dead letter queue to determine why their processing did not
succeed.

To create a dead letter queue, you must first create a redrive policy, and then set the policy in
the queue's attributes.

Important

A dead letter queue must be the same type of queue (FIFO or standard) that the source
queue is. It must also be created using the same AWS account and region as the source
queue.

Create a Redrive Policy

A redrive policy is specified in JSON. To create it, you can use the JSON utility
class provided
with the AWS SDK for C++.

Here is an example function that creates a redrive policy by providing it with the
ARN of your dead
letter queue and the maximum number of times the message can be received and not processed
before
it's sent to the dead letter queue.

Set the Redrive Policy on your Source Queue

To finish setting up your dead letter queue, call the SQSClient class'
SetQueueAttributes member function with a SetQueueAttributesRequest object for which you've set the
RedrivePolicy attribute with your JSON redrive policy.