Soru

Zorluk: ZorDecoupling Architectures and Event-Driven Messaging

An IoT-enabled smart parking management system generates vehicle entry and exit events that must be processed in the exact sequence they occur for each vehicle to calculate parking fees accurately. The events must be delivered to both a real-time billing application and an occupancy tracking dashboard. Both downstream applications must receive every event. Which solution meets these requirements while ensuring strict message ordering is preserved for each vehicle?

  1. A
    Publish the events to a standard Amazon SNS topic. Subscribe two Amazon SQS Standard queues to the topic, one for each downstream application. Configure the downstream applications to sort the events using a timestamp attribute.
  2. B
    Publish the events to an Amazon SNS FIFO topic. Subscribe two Amazon SQS Standard queues to the topic, one for each downstream application, and use the vehicle ID as the message group ID.
  3. Publish the events to an Amazon SNS FIFO topic. Subscribe two Amazon SQS FIFO queues to the topic, one for each downstream application. Use the vehicle ID as the message group ID when publishing the events.Cevap
  4. D
    Publish the events to a standard Amazon SNS topic. Subscribe two Amazon SQS FIFO queues to the topic, one for each downstream application, and use the vehicle ID as the message group ID.

Cevap

Publish the events to an Amazon SNS FIFO topic, subscribe two Amazon SQS FIFO queues to the topic, and use the vehicle ID as the message group ID when publishing.
To preserve message ordering end-to-end and deliver every message to multiple downstream consumers (fan-out), both the Amazon SNS topic and the Amazon SQS queues must be configured as FIFO (First-In-First-Out). Publishing events to an SNS FIFO topic with a specific message group ID (the vehicle ID) ensures that all messages for that vehicle are grouped and processed sequentially. The SQS FIFO queues subscribed to the SNS FIFO topic will receive the messages in the exact order they were published, allowing each consumer to process them in sequence.

Adım Adım Çözüm

1
Identify the requirement for message ordering and fan-out capability.
The application requires message ordering to be preserved per vehicle ID (ordering requirement) and messages to be delivered to two separate applications (fan-out requirement).
This dictates the choice of messaging services that support both event fan-out and first-in, first-out delivery guarantees.
2
Select the appropriate messaging services to implement a fan-out architecture.
Amazon SNS is selected for fanning out messages, and Amazon SQS is selected to act as the buffer queues for the downstream applications.
SNS allows a single published message to be distributed to multiple subscribers, while SQS queues ensure that messages are buffered and processed asynchronously without losing data.
3
Determine the required queue and topic type for strict ordering.
Select SNS FIFO and SQS FIFO instead of standard types.
Standard SNS and SQS do not guarantee message ordering. To maintain chronological sequence end-to-end, both the SNS topic and the SQS queues must be FIFO.
4
Configure the grouping identifier to order messages per vehicle.
Use the vehicle ID as the Message Group ID (MessageGroupId) when publishing to the SNS FIFO topic.
SQS FIFO and SNS FIFO use the Message Group ID to group messages. Messages within the same group are processed in strict FIFO order, while messages across different groups can be processed in parallel, optimizing performance.

Anahtar Kavram

End-to-end first-in, first-out (FIFO) message ordering in fan-out architectures using Amazon SNS FIFO and Amazon SQS FIFO.
Bu soruyu puanla