AWS Certified Developer – Associate (DVA-C02)Development with AWS ServicesEasy

A developer is building a serverless application using AWS Lambda and Amazon SQS. The Lambda function processes messages from an SQS queue. If the Lambda function fails to process a message after multiple retries, the developer wants to ensure the message is moved to a separate queue for later investigation, rather than being discarded. What SQS feature should the developer configure to achieve this?

  1. AVisibility Timeout
  2. BLong Polling
  3. CDead-Letter Queue (DLQ)
  4. DMessage Group ID
Show answer & explanation

Correct answer: C. Dead-Letter Queue (DLQ)

A Dead-Letter Queue (DLQ) is an SQS queue that other source queues can target for messages that cannot be processed successfully. By configuring a DLQ with a `redrive policy` on the source queue, messages that exceed a specified `maxReceiveCount` will be automatically moved to the DLQ for debugging and analysis, preventing data loss.

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 move messages to a separate queue if processing consistently fails.
  • B. Long polling reduces the number of empty responses by waiting for messages to arrive, but it doesn't handle failed message processing.
  • D. Message Group ID is used in SQS FIFO queues to maintain message ordering within a group, which is unrelated to handling failed message processing in standard queues.

SQS Dead-Letter Queue (DLQ)

An Amazon SQS Dead-Letter Queue (DLQ) is a standard or FIFO queue that receives messages that a source queue (e.g., a Lambda trigger) was unable to process successfully after a specified number of attempts, preventing message loss and enabling debugging.

  • Prevents message loss from failed processing.
  • Messages moved after `maxReceiveCount` is exceeded.
  • Requires a `redrive policy` on the source queue.
  • Allows for later investigation and re-processing.
  • Can be a Standard or FIFO queue.

Memory trick: DLQ 'Directs' 'Discarded' 'Loads' for 'Diagnosis'.

More Development with AWS Services questions