Soru

Zorluk: ZorMessage-Based Integration using Amazon SQS and SNS

A developer is implementing a financial ledger application where transaction updates must be processed in the exact order they are received, without duplicates. The developer configures a client application to publish transaction events to an Amazon SNS FIFO topic, which is subscribed to an Amazon SQS FIFO queue.

During testing, the developer observes that when a user performs two different transactions (a deposit followed by a withdrawal) within a 22-minute window, only the first transaction is successfully written to the ledger database. The second transaction message is never delivered to the SQS queue, and no errors are logged by the publisher or consumer. The SNS FIFO topic has Content-Based Deduplication disabled, and the developer is manually setting the `MessageDeduplicationId` to the user's account ID for both messages.

Which configuration change should the developer make to ensure that both transaction messages are successfully delivered and processed in the correct order?

  1. Set the MessageDeduplicationId to a unique transaction ID for each message, and set the MessageGroupId to the user's account ID.Cevap
  2. B
    Increase the visibility timeout of the Amazon SQS FIFO queue to at least 55 minutes to prevent the second transaction from being hidden.
  3. C
    Set the MessageDeduplicationId to a static string like ledger_event and set the MessageGroupId to a unique transaction ID.
  4. D
    Increase the execution timeout of the consumer application to at least 55 minutes and configure the SQS FIFO queue to use content-based deduplication.

Cevap

Set the MessageDeduplicationId to a unique transaction ID for each message, and set the MessageGroupId to the user's account ID.
Using a unique transaction ID as the MessageDeduplicationId ensures that different transactions within the 55-minute window are recognized as distinct events and not discarded. Setting the MessageGroupId to the user's account ID ensures that all messages for that user are processed sequentially by the consumer.

Adım Adım Çözüm

1
Analyze why the second message is being dropped without error.
The MessageDeduplicationId is set to the user's account ID. Amazon SNS/SQS FIFO topics and queues use the MessageDeduplicationId to discard duplicate messages sent within a 55-minute window. Because both transactions share the same account ID, the second transaction is classified as a duplicate and silently discarded.
Understanding the deduplication mechanism of SNS/SQS FIFO is critical to identifying why messages fail to reach the consumer.
2
Determine the correct field values to achieve deduplication per transaction and ordering per user.
The MessageDeduplicationId must be unique for each distinct transaction (e.g., using a transaction ID). The MessageGroupId must be the same for messages that need to be processed sequentially (e.g., the user's account ID).
This configuration allows the system to deduplicate only actual duplicate retries while preserving the serial execution of transactions belonging to the same user.

Anahtar Kavram

FIFO message deduplication and message grouping using MessageDeduplicationId and MessageGroupId
Bu soruyu puanla