How does SNS integrate with SQS in the fan out pattern to support multiple independent consumers of the same event?
Short answer
In the SNS to SQS fan out pattern, a single event is published once to an SNS topic, which then delivers a copy of that message to multiple separate SQS queues that are each subscribed to the topic, allowing multiple independent consumer applications to process the exact same…
Advertisement
AModel answer
In the SNS to SQS fan out pattern, a single event is published once to an SNS topic, which then delivers a copy of that message to multiple separate SQS queues that are each subscribed to the topic, allowing multiple independent consumer applications to process the exact same event at their own pace, with each queue providing durability and retry handling independently, without one slow consumer affecting the others.
Example
aws sns subscribe --topic-arn arn:aws:sns:us-east-1:123456789012:OrderEvents --protocol sqs --notification-endpoint arn:aws:sqs:us-east-1:123456789012:InventoryQueue
Real-world example
An order processing platform publishes a single order placed event to SNS, which fans it out to three separate SQS queues feeding independent inventory, shipping, and analytics services, each processing the event on its own schedule without interfering with the others.
Likely follow-ups
- What are the advantages of the fan out pattern compared to publishing directly to multiple queues?
- How do you handle a message that fails processing in one of the fan out queues?
Related topics