In SOFAStack message queues, topics and tags are identifiers used to categorize messages. A topic is a level 1 category, and a tag is a level 2 category. This article explains how to use topics and tags together for message filtering.
Background information
Topics and tags are defined as follows:
Topic: A message topic used to classify different business messages.
Tag: A message tag used to further classify messages within a topic. A tag is a property attached to a message by the producer.
The following figure shows the relationship between topics and tags.

Scenarios
A common question is when to use a topic and when to use a tag.
Consider the following aspects to make your decision:
Message type consistency: Use different topics for different message types, such as normal, transactional, scheduled or delayed, and ordered messages. When you create a topic, you must specify its message type. You cannot use tags to differentiate message types.
Business relevance: Use different topics for messages that are not directly related, such as payment messages, credit score messages, and membership messages. For related messages within the same business domain, use tags. For example, you can use tags to differentiate between payment types such as direct payments, red packet notifications, and transfers, all under a single payment topic.
Message volume: Some messages have low volume but require high real-time performance. If these messages share a topic with very high-volume messages, they might experience long delays. To prevent this, separate messages with different volumes into different topics.
To summarize, you can classify messages by creating multiple topics or by creating multiple tags under a single topic. Typically, messages in different topics are unrelated. Use tags to distinguish related messages within the same topic, such as subsets of a larger message set or messages representing different stages in a workflow.
Notes
If a topic has multiple tags, you cannot monitor the consumption progress or backlog size for each individual tag. The tags also affect each other's performance. For example, consider a topic with Tag 1 and Tag 2. If the consumption of messages with Tag 2 is slow, it also slows down the consumption of messages with Tag 1. If Tag 1 has a backlog of 100 messages and Tag 2 has a backlog of 200, you can only see the total topic backlog of 300. You cannot determine the specific backlog size or consumption progress for each tag.
To avoid performance interference between tags, use multiple topics. If you use this approach, evaluate your total peak traffic. If your required quota exceeds 5000, you must provision additional machine resources.