A high-volume logistics application uses an Amazon SQS standard queue to buffer telemetry data from delivery vehicles. A worker process retrieves messages, performs geo-spatial calculations, and writes the results to an Amazon DynamoDB table. The worker process takes up to seconds to process each telemetry payload. Currently, the SQS queue visibility timeout is set to seconds. Consequently, some telemetry records are duplicated in the DynamoDB table. Which two actions should the developer take to resolve this duplication issue?
- Increase the default visibility timeout of the SQS queue to seconds, ensuring it exceeds the maximum message processing time.Answer
- Modify the worker application to call the ChangeMessageVisibility API operation to extend the visibility timeout of a message during active processing.Answer
- CDecrease the default visibility timeout of the SQS queue to seconds so that failed messages are retried faster.
- DHardcode static AWS access keys inside the worker application's SDK client configuration to reduce latency during credential resolution.
- EStore the application's processing state in static, global variables to maximize execution context reuse, assuming the connection pool persists without cleanup.
Answer
To resolve the duplication, the developer must increase the SQS queue's default visibility timeout to seconds and modify the worker application to dynamically call the ChangeMessageVisibility API operation during active processing.
The issue is caused by the message processing duration ( seconds) exceeding the default visibility timeout ( seconds). Increasing the visibility timeout to seconds ensures the message is not visible to other consumers during the transaction. Additionally, invoking the ChangeMessageVisibility API dynamically extends the timeout for slow messages, handling unexpected latency without permanently locking failed messages.
Step-by-Step Solution
Key Concept
Amazon SQS Message Visibility Timeout management and dynamic visibility updates using ChangeMessageVisibility.