Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a medical report analysis service where PDF files are processed by a consumer application. The application retrieves processing tasks from an Amazon SQS queue. Each task takes exactly 4040 seconds to complete. The developers observe that the same reports are frequently processed multiple times, causing duplicate entries in the database. Which configuration change will prevent these duplicate processing events?

  1. Increase the SQS visibility timeout to a value greater than 4040 seconds.Cevap
  2. B
    Decrease the SQS visibility timeout to 2020 seconds to allow faster retries.
  3. C
    Increase the execution timeout of the consumer application without changing the queue settings.
  4. D
    Store long-lived AWS credentials inside the consumer application code to reduce authorization overhead.

Cevap

Increase the SQS visibility timeout to a value greater than 4040 seconds.
Increasing the SQS visibility timeout to a value greater than the message processing time (in this case, greater than 4040 seconds) ensures that the message remains invisible to other consumers while the active consumer is processing it. This prevents other consumers from retrieving and processing the same message simultaneously, resolving the duplicate processing issue.

Adım Adım Çözüm

1
Analyze the cause of duplicate processing in SQS.
The message becomes visible to other consumers before the active consumer finishes processing.
When a message is received from a queue, it remains in the queue but is hidden for the duration of the visibility timeout. If processing takes longer than this timeout, the message becomes visible again and can be processed by another consumer.
2
Compare the processing duration with the current configuration constraints.
The visibility timeout must be set to a duration longer than the 4040 seconds required for task execution.
To prevent other consumers from picking up the message, the visibility timeout must cover the entire processing window plus some buffer.
3
Select the correct option to modify the queue's settings.
Configure the visibility timeout of the SQS queue to be greater than 4040 seconds.
This configuration directly addresses the root cause of duplicate processing without modifying application timeouts or using insecure credentials.

Anahtar Kavram

SQS visibility timeout configuration relative to consumer processing time.
Tahmini Süre:1m 30s
Bu soruyu puanla