Question

Difficulty: EasyMessage-Based Integration using Amazon SQS and SNS

A developer is troubleshooting an application that processes message payloads from an Amazon SQS queue. The application requires an average of 45 seconds to successfully process and delete each message. Currently, the same messages are being received and processed multiple times by the application. Which configuration change will prevent this behavior?

  1. A
    Reduce the queue's Visibility Timeout parameter to 10 seconds to expedite message recycling.
  2. B
    Increase the execution timeout of the consumer's AWS Lambda function without modifying queue settings.
  3. Modify the SQS queue settings to increase the Visibility Timeout parameter to a duration greater than 45 seconds.Answer
  4. D
    Embed raw AWS IAM credentials directly in the application code to speed up SDK client initialization.

Answer

Modify the SQS queue settings to increase the Visibility Timeout parameter to a duration greater than 45 seconds.
The correct option is to modify the SQS queue settings to increase the Visibility Timeout parameter to a duration greater than 45 seconds. Amazon SQS uses the visibility timeout to prevent other consumers from processing a message while a current consumer is processing it. If the processing time is 45 seconds, the visibility timeout must be set to a value greater than 45 seconds (such as 60 seconds) to ensure the message is deleted before it becomes visible again.

Step-by-Step Solution

1
Analyze the relationship between processing duration and visibility timeout.
The message processing takes 45 seconds, which exceeds the default visibility timeout.
If visibility timeout is shorter than processing time, the message becomes visible to other consumers before the current consumer can delete it.
2
Identify the SQS configuration parameter that controls message visibility lock.
The Visibility Timeout parameter controls this duration.
Adjusting the Visibility Timeout guarantees that the message remains hidden until processing is complete.
3
Set the Visibility Timeout to a safe threshold.
The Visibility Timeout is set to a value greater than 45 seconds (e.g., 60 seconds).
This allows the application sufficient time to process and delete the message without duplicates.

Key Concept

SQS Visibility Timeout vs Message Processing Duration
Rate this question