This topic describes how to push MNS messages to multiple queues by using message filter tags.

Background information

In most cases, MNS pushes messages to specified queues after you create a subscription. If you do not configure a message filter tag for a message or subscription, the message can be pushed to a specified queue.

If you configure a message filter tag for a message and configure a message filter tag for a subscription, the message can be pushed to a specified queue only when both tags are the same.

If you do not configure a message filter tag for a subscription, a message can be pushed to a specified queue regardless of whether you configure a message filter tag for the message.

Scenarios

In some scenarios, you may need to push messages to multiple queues based on the message content. To do so, you can create multiple topics and configure queues for each topic. However, it incurs additional costs and makes O&M more complex. To address this issue, MNS allows you to specify message filter tags when you create a subscription. Then MNS pushes the messages to multiple queues. In this case, you do not need to create multiple topics.

Example

The following figure shows how messages that have different message filter tags are filtered by the tags of subscriptions and pushed to destination queues.

Filter messages

In this scenario, three subscriptions that have different message filter tags are created in Topic 1. Three messages are respectively pushed to Queue 1, Queue 2, and Queue 3.

  • The following process describes how messages are filtered if the messages and subscriptions have the same message filter tags:
    • MNS pushes Message 1 to Queue 1.
    • MNS pushes Message 2 to Queue 2.
  • The following process describes how messages are filtered if no message filter tags are configured for the subscriptions:
    • MNS pushes Message 1 to Queue 3.
    • MNS pushes Message 2 to Queue 3.
    • MNS pushes Message 3 to Queue 3.