Message filtering for FIFO topics - Amazon Simple Notification Service

Message filtering for FIFO topics

Amazon SNS FIFO topics support message filtering. Using message filtering simplifies your architecture by offloading the message routing logic from your publisher systems and the message filtering logic from your subscriber systems.

When you subscribe an Amazon SQS FIFO queue to an SNS FIFO topic, you can use message filtering to specify that the subscriber receives a subset of messages, rather than all of them. Each subscriber can set its own filter policy as a subscription attribute. If the filter policy matches the incoming message's attributes, the topic delivers a copy of the message to the subscriber. If there's no match, the topic doesn't deliver a copy of the message.

In the auto parts price management example use case, assume that the following Amazon SNS filter policies are set:

  • For the wholesale queue, the filter policy {"business":["wholesale"]} matches every message with an attribute named "business" and with "wholesale" in the set of values. In the following diagram, the attribute in message m1 is String with a value of "wholesale". The attribute in message m3 is String.Array with a value of "wholesale,retail". Thus, both m1 and m3 match the filter policy's criteria, and both messages are delivered to the wholesale queue.

  • For the retail queue, the filter policy {"business":["retail"]} matches every message with an attribute named "business" and with "retail" in the set of values. In the diagram, the attribute in message m2 is String with a value of "retail". The attribute in message m3 is String.Array with a value of "wholesale,retail". Thus, both m2 and m3 match the filter policy's criteria, and both messages are delivered to the retail queue.

The following diagram shows the effect of messaging filtering using these filter policies.


        Message filtering for SNS FIFO topics.

SNS FIFO topics support a variety of matching operators, including attribute string values, attribute numeric values, and attribute keys. For more information, see Amazon SNS message filtering.

SNS FIFO topics don't deliver duplicate messages to subscribed endpoints. For more information, see Message deduplication for FIFO topics.