Volume 10 · Chapter 8 — Messaging and Event-Driven Architecture
SNS Deep Dive and Amazon MQ
8.1 Introduction
The pub/sub chapter covered SNS fan-out; the exam expects the deeper SNS features (FIFO topics, message filtering, delivery/DLQ, mobile push) and awareness of Amazon MQ - the managed traditional message broker for migrating existing applications. This chapter covers both.
8.2 SNS Features: FIFO, Filtering, and Delivery
SNSpublishes a message to a topic and delivers a copy to all subscribers.FIFO topics(paired with FIFO SQS queues) provide ordered, deduplicated fan-out where order matters.Message filteringuses subscriptionfilter policiesso each subscriber receives only messages matching attributes it cares about - one topic carries varied events and each consumer gets its relevant subset, reducing unnecessary processing. SNS handlesdelivery retrieswith policies and supports adead-letter queueper subscription for messages that can’t be delivered. Subscribers include SQS, Lambda, HTTP/S, email, SMS, and mobile push. The exam pattern: SNS FIFO for ordered fan-out, message filtering to route subsets, and subscription DLQs for undeliverable messages.
flowchart TB Pub[Publisher] --> Topic[(SNS topic)] Topic -->|filter policy: payments| Q1[(SQS: payments)] Topic -->|filter policy: alerts| Q2[(SQS: alerts)] Topic --> Lam[Lambda] Topic --> Push[Mobile push / SMS / email] Topic -.undeliverable.-> DLQ[(Per-subscription DLQ)]
8.3 The SNS-to-SQS Fan-Out Pattern (Recap and Depth)
The cornerstone pattern subscribes multiple SQS queues to one SNS topic, so an event fans out to each service’s own durable queue - combining SNS’s one-to-many delivery with each queue’s buffering, retries, DLQ, and independent scaling. This is preferred over subscribing consumers directly to SNS because the queue ensures a consumer that’s temporarily down doesn’t miss the event (it waits durably). With message filtering, each queue receives only its relevant events. The exam repeatedly favours SNS→SQS fan-out for reliable, decoupled, independently-scaled distribution of an event to multiple consumers - the reliable event-distribution backbone.
8.4 Amazon MQ
Amazon MQis a managed message broker forApache ActiveMQandRabbitMQ. Unlike the cloud-native SQS/SNS (which use AWS APIs), Amazon MQ supportsindustry-standard protocols(JMS, AMQP, MQTT, STOMP, OpenWire) - so it’s the answer when you’remigrating an existing applicationthat already uses a traditional message broker and those protocols, and you want minimal code changes (lift-and-shift). For new cloud-native applications you’d choose SQS/SNS for their scalability and serverless operation; Amazon MQ is specifically for compatibility with existing broker-based apps. The exam pattern: SQS/SNS for new cloud-native messaging; Amazon MQ to migrate an app that already depends on ActiveMQ/RabbitMQ and standard messaging protocols.
8.5 Banking Production Scenario
A bank distributes its “PaymentMade” event via SNS-to-SQS fan-out: the payment service publishes to an SNS topic and the notification, fraud, ledger, and analytics services each subscribe an SQS queue, with filter policies so each receives only relevant event types and per-subscription DLQs for undeliverable messages; a FIFO topic handles an ordered downstream flow. Customer push notifications and SMS alerts go through SNS mobile push. A legacy trading application that already uses JMS on ActiveMQ is migrated with Amazon MQ, preserving its protocol and requiring minimal code change, while new services use SQS/SNS. This deliberate use of cloud-native messaging plus Amazon MQ for migration is exactly the professional-level design the certification targets.
8.6 Chapter Revision Notes
- SNS FIFO topics (with FIFO SQS) give ordered, deduplicated fan-out; message filtering (filter policies) delivers each subscriber only its relevant subset.
- SNS supports delivery retries and per-subscription DLQs; subscribers include SQS, Lambda, HTTP/S, email, SMS, mobile push.
- SNS→SQS fan-out (a queue per subscriber) is preferred for reliable distribution - buffering, retries, DLQ, independent scaling; a down consumer doesn’t miss events.
- Amazon MQ = managed ActiveMQ/RabbitMQ supporting standard protocols (JMS, AMQP, MQTT, STOMP) - for migrating existing broker-based apps.
- New cloud-native → SQS/SNS; migrating an existing broker app → Amazon MQ.