Course menuSAA-C03

Exams / SAA-C03 / Decoupling with queues / Question 5

SAA-C03 practice question: Decoupling with queues (5 of 6)

Design Resilient Architectures A free question from our original SAA-C03 practice exam. Try it, then open the answer to see why each option is right or wrong.

An order-processing application reads messages from an Amazon SQS standard queue. A few malformed messages fail every time a worker tries to process them, so they keep returning to the queue and use up worker time that valid messages need. The team wants these failing messages moved aside automatically after a few attempts, and kept so that a developer can inspect them and replay them later. What should a solutions architect do?

Choose one answer.

  1. A. Lower the queue's message retention period to 1 hour, so that messages that keep failing expire and are removed from the queue.
  2. B. Create another SQS queue as a dead-letter queue, and give the source queue a redrive policy with a maximum receive count of 5.
  3. C. Change the workers to delete any message that fails processing, and write the message body to Amazon CloudWatch Logs for review.
  4. D. Increase the queue's visibility timeout to 12 hours, so that failing messages are retried less often and valid messages go first.
Show the answer and explanation

Answer: B

  • A. Wrong: A shorter retention period would delete the failing messages, but it would also delete valid messages that wait longer than an hour. The failing messages would be lost, so nobody could inspect or replay them. Learn more: Configuring queue parameters using the Amazon SQS console (opens in a new tab)
  • B. Right: Correct. After a message has been received the set number of times without being deleted, SQS moves it to the dead-letter queue. The message is kept there for developers to inspect, and it can be redriven back to the source queue once the bug is fixed. Learn more: Using dead-letter queues in Amazon SQS (opens in a new tab)
  • C. Wrong: This removes the failing messages from the queue, but it needs code changes and deletes a message after a single failure, including one that failed for a passing reason. Replaying from log entries is also manual. A dead-letter queue does this without code.
  • D. Wrong: A long visibility timeout hides a failed message for longer, but it keeps coming back forever and is never set aside. It also delays the retry of valid messages that failed for a temporary reason. A dead-letter queue is built for this. Learn more: Amazon SQS visibility timeout (opens in a new tab)

Explanation

A dead-letter queue isolates messages that cannot be processed. The source queue's redrive policy sets a maximum receive count; once a message exceeds it, SQS moves the message to the dead-letter queue, where it can be inspected and later redriven. The other options either lose the messages or keep retrying them.

Study

Keep practising

Answer questions with a score at the end, or practise just this topic with the explanation after each one. No sign-up needed.