Question

Difficulty: MediumDecoupling Architectures and Event-Driven Messaging

A logistics company uses a microservices-based application to track cargo pallet lifecycle events such as received, scanned, sorted, and loaded. If these updates are processed out of sequence, the inventory database becomes corrupted. The company needs to decouple the ingestion service from the backend database while ensuring that the updates for each individual pallet are processed in the exact chronological order in which they were generated. Which solution meets these requirements with the least operational overhead?

  1. A
    Publish the updates to an Amazon SQS Standard queue, and configure a message deduplication ID based on the event timestamp to guarantee chronological ordering.
  2. Publish the updates to an Amazon SQS FIFO queue, using the pallet ID as the message group ID, and use consumer instances to process the messages.Answer
  3. C
    Publish the updates to an Amazon SNS Standard topic, and subscribe multiple Amazon SQS Standard queues to process the updates in parallel.
  4. D
    Publish the updates to an Amazon SQS Standard queue, and use Message Group IDs to group and order the messages during consumer retrieval.

Answer

Publishing the updates to an Amazon SQS FIFO queue, using the pallet ID as the message group ID, and using consumer instances to process the messages is the correct solution.
Publishing the updates to an Amazon SQS FIFO queue ensures that messages are processed in the exact order they are received. Using the pallet ID as the message group ID ensures that events for any single pallet are processed sequentially, preventing database corruption, while enabling parallel processing of different pallets across multiple consumers.

Step-by-Step Solution

1
Analyze the ordering and decoupling requirements.
The application requires message decoupling and strict message ordering per pallet to prevent database corruption.
If messages are processed out of order, the inventory status of a pallet will become incorrect.
2
Evaluate Amazon SQS queue options for ordering guarantees.
Select Amazon SQS FIFO queues instead of SQS Standard queues.
SQS Standard queues only offer best-effort ordering, whereas SQS FIFO queues guarantee that messages are processed in the exact order they are received.
3
Configure the partitioning/grouping strategy for concurrent processing.
Use the pallet ID as the Message Group ID on the SQS FIFO queue.
This guarantees that updates for the same pallet are processed in order, while allowing different pallets to be processed concurrently by multiple consumers.

Key Concept

Amazon SQS FIFO queues provide first-in, first-out delivery. By using Message Group IDs, you can group messages so that messages within the same group are processed in order, while allowing multiple consumer instances to process different groups in parallel.
Rate this question