AWS Certified Developer – Associate (DVA-C02)Development with AWS ServicesMedium
A developer is building a serverless application where an AWS Lambda function processes data from an Amazon SQS queue. The data processing can sometimes fail due to transient issues or malformed messages. To prevent lost messages and allow for later inspection and reprocessing, which SQS feature should the developer configure?
- AVisibility Timeout
- BMessage Timers
- CLong Polling
- DDead-Letter Queue (DLQ)
Show answer & explanationAnswer & explanation
Correct answer: D. Dead-Letter Queue (DLQ)
A Dead-Letter Queue (DLQ) is used to store messages that a source queue is unable to process successfully after a certain number of retries. This prevents messages from being lost and allows developers to inspect and troubleshoot failed messages.
Why the other options are wrong
- A. Visibility Timeout prevents other consumers from processing a message that is currently being processed, but it doesn't handle messages that consistently fail.
- B. Message Timers delay the delivery of messages to a queue, not for handling processing failures.
- C. Long Polling reduces the number of empty responses by waiting for messages to arrive, not for handling failed messages.
SQS Dead-Letter Queue (DLQ)
A separate queue where Amazon SQS can send messages that a source queue's consumer fails to process successfully after a maximum number of retries.
- Prevents messages from being lost due to repeated processing failures.
- Allows developers to isolate, inspect, and reprocess problematic messages.
- Configured with a `redrive policy` on the source queue.
Memory trick: When SQS messages 'die' from processing failures, they go to the DLQ for review.