Q59 — AWS DVA-C02 Ch.3

Question 59 of 100 | ← Chapter 3

A company has an AWS Lambda function that uses the Amazon SQS API to read messages from an Amazon Simple Queue Service (Amazon SQS) queue. Due to random failures of a downstream dependency, the Lambda function fails to process all messages successfully. The developer needs to enhance the reliability of the Lambda function so that it can successfully process each message even when the downstream dependency fails. Which solution requires the least effort to meet this requirement?

Correct Answer: D. Create a second SQS queue to serve as a dead-letter queue. Move the calls to the third-party dependency into an exception-handling block. If a failure in the third-party dependency is caught in the exception handler, write the message to the dead-letter queue.

Explanation

To improve the reliability of the Lambda function with minimal effort and ensure messages are processed successfully even when third-party dependencies fail, the best practice is to combine exception handling with a dead-letter queue. Option D satisfies both conditions: first, it places calls to the third-party dependency inside an exception-handling block to catch failures; second, it writes failed messages to a dead-letter queue, ensuring messages are not lost and can be retried or analyzed later. This approach guarantees message reliability while simplifying code logic, making it the optimal choice. 【Lantern Certification provided by: swufelp1999】