How does message filtering work in SNS to control which subscribers receive specific messages?
Short answer
SNS message filtering lets each subscriber attach a filter policy to their subscription, describing specific message attribute values they are interested in, so that a subscriber only receives messages matching their filter policy rather than every single message published to…
Advertisement
AModel answer
SNS message filtering lets each subscriber attach a filter policy to their subscription, describing specific message attribute values they are interested in, so that a subscriber only receives messages matching their filter policy rather than every single message published to the topic, allowing multiple subscribers with very different interests to share the same topic efficiently.
aws sns set-subscription-attributes --subscription-arn arn:aws:sns:us-east-1:123456789012:OrderAlerts:abc123 --attribute-name FilterPolicy --attribute-value '{"order_type":["international"]}'Real-world example
A logistics company uses a single SNS topic for all order events, but a subscriber responsible only for international shipping sets a filter policy so it only receives notifications for orders with an international order type attribute.
Likely follow-ups
- What attributes can be used within a filter policy?
- How does filtering affect the cost of using SNS?
Related topics