SAA-C03 ยท Decoupling and serverless patterns
Amazon SNS and fan-out
Publish/subscribe with SNS topics, subscriber types, the SNS-to-multiple-SQS fan-out pattern and message filtering.
Key points
- SNS: publish/subscribe; a producer publishes once to a topic, SNS pushes a copy to every subscription.
- Subscribers: SQS queues, Lambda, Amazon Data Firehose, HTTP/S endpoints, or people (email, SMS, mobile push).
- Fan-out: several SQS queues on one topic; each service gets its own durable copy at its own pace.
- Filter policy: a subscription receives only the messages it cares about.
Source: https://docs.aws.amazon.com/sns/latest/dg/sns-event-destinations.html
Practice questions
A subscription to an SNS topic has no filter policy. Which messages does it receive?
- No messages until a filter policy is added
- Only messages that carry message attributes
- Every message published to the topic
- Only messages sent after it was confirmed twice
Show answer
Answer: C. Every message published to the topic
Without a filter policy a subscriber gets every message published to the topic. Filtering only happens when you attach a filter policy to that subscription.
Which of these can be subscribed directly to an SNS standard topic?
- An Amazon SQS queue
- An AWS Lambda function
- An Amazon EBS volume
- An HTTPS webhook endpoint
- An Amazon RDS table
Show answer
Answer: A. An Amazon SQS queue, B. An AWS Lambda function, D. An HTTPS webhook endpoint
SQS queues, Lambda functions and HTTP/S endpoints are all supported application-to-application destinations. An EBS volume and an RDS table are storage, not subscription endpoints; to land messages there you need a consumer such as a Lambda function.
An SNS topic keeps published messages so that a subscriber which was offline can poll the topic later and collect them.
Show answer
Answer: False
False. SNS pushes messages to subscribers; there is no polling of a topic. For a consumer that may be offline, subscribe an SQS queue: the queue persists the copy until the consumer reads it.
Practice 8 questions on this topic in Bitzu
Short lessons, instant explanations and spaced review of what you get wrong. Free on iOS and Android.
