A company runs an application on multiple Amazon EC2 instances that processes messages from an Amazon SQS queue, writes to an Amazon RDS table, and then deletes the message from the queue. Occasional duplicate records appear in the RDS table even though the SQS queue has no duplicate messages. What should a solutions architect do to ensure messages are processed only once?
Choose an answer
Tap an option to check your answer.
Correct answer: Use the ChangeMessageVisibility API call to increase the visibility timeout..
Why this is the answer
The correct answer is to use the ChangeMessageVisibility API call to increase the visibility timeout. When an EC2 instance receives a message from an SQS queue, the message becomes temporarily invisible to other consumers. If the instance fails to process and delete the message before the visibility timeout expires, the message becomes visible again and can be processed by another instance, leading to duplicate processing and duplicate records in the RDS table. Increasing the visibility timeout gives the processing instance more time to complete its work and delete the message, preventing other instances from seeing and processing it again. Using CreateQueue or AddPermission will not address the issue of duplicate processing. Setting an appropriate wait time with ReceiveMessage can reduce the number of empty responses but doesn't prevent duplicate processing if the original processor fails.
Pass your exam — without the endless answer hunt
Get every verified question and explanation for this exam in one place, and save hours of prep. 1,000+ certifications · 20+ languages · free to start.
Pass your exam faster → No card needed