Soru

Zorluk: OrtaMessage-Based Integration using Amazon SQS and SNS

A developer is designing a decoupled backend for a ridesharing application to handle completed trip events. When a trip ends, the system publishes a trip event that must be processed by two independent microservices:

1. A trip analytics service that calculates aggregate metrics and consumes messages from an Amazon SQS Standard queue.
2. A financial ledger service that updates customer balances in the exact order the trips occurred, utilizing an Amazon SQS FIFO queue.

The developer wants to implement a fanout pattern using Amazon SNS to distribute these events.

Which architectural configuration will successfully support this integration?

  1. Create an Amazon SNS Standard topic to publish events to the SQS Standard queue, and create a separate Amazon SNS FIFO topic to publish events to the SQS FIFO queue.Cevap
  2. B
    Create a single Amazon SNS FIFO topic, subscribe both the SQS Standard queue and the SQS FIFO queue to it, and configure the SQS Standard queue visibility timeout to zero.
  3. C
    Create a single Amazon SNS Standard topic, subscribe the SQS Standard queue to it, and route messages to the SQS FIFO queue via an AWS Lambda function that maintains ordering using persistent execution context variables.
  4. D
    Create a single Amazon SNS Standard topic, subscribe both queues to it, and initialize the downstream AWS SDK clients using static IAM user access keys.

Cevap

Create one Amazon SNS Standard topic to publish events to the SQS Standard queue, and create a separate Amazon SNS FIFO topic to publish events to the SQS FIFO queue.
The correct configuration uses two separate SNS topics (one Standard and one FIFO) to publish to their respective SQS queues. This is required because Amazon SNS FIFO topics only support subscriptions from SQS FIFO queues, and Standard SQS queues cannot subscribe to SNS FIFO topics. Similarly, SQS FIFO queues cannot subscribe to Standard SNS topics. To support both downstream consumer types, separate paths must be implemented.

Adım Adım Çözüm

1
Analyze SQS queue requirements.
The analytics service uses a standard SQS queue, whereas the ledger service requires a FIFO SQS queue for strict ordering.
Different downstream services have different order and throughput requirements.
2
Evaluate Amazon SNS and SQS integration constraints.
Standard SQS queues cannot subscribe to SNS FIFO topics, and SQS FIFO queues cannot subscribe to standard SNS topics.
AWS enforces protocol homogeneity between standard and FIFO tiers to ensure ordering guarantees are maintained.
3
Formulate the fanout architecture.
Create a standard SNS topic to target the standard SQS queue, and a FIFO SNS topic to target the FIFO SQS queue.
Since a single SNS topic cannot fan out to both queue types due to subscription rules, the publisher must send events to both a standard and a FIFO topic.

Anahtar Kavram

Integration compatibility rules between Amazon SNS topics (Standard/FIFO) and Amazon SQS queues (Standard/FIFO).
Bu soruyu puanla