AWS Certified Developer – Associate (DVA-C02) — Question 501
A developer needs to build a workflow to handle messages that are sent to an Amazon Simple Queue Service (Amazon SQS) queue. When a message reaches the queue, the workflow must implement a delay before invoking an AWS Lambda function to process the message.
Which solution will meet this requirement in the MOST operationally efficient way?
Answer options
- A. Create an AWS Step Functions state machine to process the SQS queue. Use a Wait state to delay the Lambda function’s processing for the required number of seconds after message delivery to the SQS queue. Use Amazon EventBridge to invoke the state machine every 5 minutes.
- B. Configure the Lambda function to poll the SQS queue. Update the Lambda code to republish each message with a custom attribute that contains a future time when the message should be fully processed. Update the Lambda code to fully process messages when the custom attribute’s future time has passed.
- C. Set the DelaySeconds value of the SQS queue to be the number of seconds required to delay delivery of the messages. Add an event source mapping for the Lambda function. Specify the SQS queue as a source.
- D. Set the Visibility Timeout value of the SQS queue to be the number of seconds required to delay delivery of the messages. Add an event source mapping for the Lambda function. Specify the SQS queue as a source.
Correct answer: C
Explanation
Setting the DelaySeconds parameter on an Amazon SQS queue (creating a delay queue) natively postpones the delivery of new messages to consumers, making it the most operationally efficient way to delay AWS Lambda processing via an event source mapping. Option D is incorrect because the Visibility Timeout controls how long a message is hidden from other consumers after it has already been read, rather than delaying its initial delivery. Options A and B are incorrect because they introduce unnecessary architectural complexity, custom code, and additional costs compared to the native SQS delay feature.