Understanding topic filters and wildcard expressions
- Last UpdatedApr 24, 2025
- 1 minute read
Subscribing to a large topic space by way of a single parent topic can result in thousands or tens of thousands of updates and may have a significant impact on system performance.
Subscribers should balance the convenience of subscribing to a single topic against the cost of receiving unwanted updates. Topic filters may be a better solution. Topic filters use pattern matching for the topic name, replacing a node in the topic with a pipe-delimited, pattern-matching expression.
The PubSub Engine supports the use of a pattern-matching wildcard expression (|*|) that may appear anywhere in the topic name except at the beginning, or even multiple times in the topic. However, a filter with one wildcard expression as the last node is the equivalent of no filter; that is, the topics a.b.|*| and a.b will return the same results.
Persistence stores may apply different rules than the PubSub Engine when interpreting wildcard expressions and topic filters.
The following table provides examples of topic filters:
|
Valid |
Invalid |
|
a.|*|.c a.b.|*| a.|*|.c.|*|.e |
|*| |*|.b.c |
Subscriptions to topic names with an invalid topic filter will never receive any publications.