Wildcard Characters in Topic Subscriptions
When the *
and >
characters are used in SMF topic subscriptions, they function as wildcards, which affect the topic matches that may occur.
The *
and >
characters don't have any special meaning when they are used in published topics. They are treated as literal characters - not as wildcards - and don't affect topic matches. However, to avoid confusion, Solace does not recommend using *
and >
as literal characters in published topics.
Using the * Wildcard
The *
wildcard functions in the following ways:
-
When
*
appears by itself at a level within a topic subscription (as in,animals/*/cats
, oranimals/domestic/*
) indicates a wildcard match at that level.A
*
wildcard at the end of a topic subscription performs a wildcard match only at that level.Example:
animals/domestic/*
matches the topicsanimals/domestic/cats
andanimals/domestic/dogs
, but it doesn't match the topicanimals/domestic/dogs/beagles
. -
When
*
is preceded by a topic prefix at a level within a topic subscription (as in,animals/red*/wild
) indicates a "prefix and 0 or more” match at that level.Example:
animals/red*/wild
matches both the topicsanimals/red/wild
andanimals/reddish/wild
. -
The
*
may be used at multiple levels within a topic subscription, with or without topic prefixes.Example:
animals/*/cats/*
is valid and matches the topicsanimals/domestic/cats/persian
andanimals/wild/cats/leopard
, but doesn't match the topicanimals/domestic/cats/persian/grey
, nor does it match the topicanimals/domestic/dogs/beagles
. -
Use of
*
in an arbitrary location within a level, and not covered by the previous rules, is treated as a literal character; general sub-string matching is not supported.Example: The
*
in topic subscriptionsanimals/*bro
andanimals/br*wn
is treated as a literal*
, not a wildcard.
Using the > Wildcard
The >
wildcard functions in the following ways:
-
When
>
appears by itself at the last level of a topic subscription (as in,animals/domestic/>
) provides a “one or more” wildcard match for any topics with an identical prefix to the subscription.Example:
animals/domestic/>
doesn't match the topicanimals/domestic
, but it does match the topicsanimals/domestic/cats
,animals/domestic/dogs
,animals/domestic/dogs/beagles
, andanimals/domestic/dogs/beagles/long-eared
. -
A
>
that appears anywhere other than by itself at the last level of a topic subscription in the string is treated as the>
character rather than a wildcard.Example:
animals>
andanimals/domestic>
are literal subscriptions and don't matchanimals/domestic/dogs/beagles
. -
The
>
and*
characters can be used together within a topic subscription.Example:
animals/*/cats/>
matches the topicsanimals/domestic/cats/persian
,animals/wild/cats/leopard
, andanimals/domestic/cats/persian/grey
, but it doesn't match the topicanimals/domestic/dogs/beagles
.
Wildcard Restrictions
Wildcards have the following restrictions:
-
Event brokers automatically create topic subscriptions beginning with the prefix
#P2P
for each client, which enables messages to be sent directly to that client (for example, in request/reply scenarios). Therefore, to ensure that wildcards cannot be used to receive messages that are intended for the inboxes of other clients, the*
or>
wildcards will never match the string#P2P
, regardless of where the wildcard or#P2P
string is located within the topic subscription string. -
Messages published to topics that begin with a
$
character will never be matched by standalone wildcards (*/..
. or>
) at the first level of a topic subscription. This ensures that system and event log messages beginning with a$
character aren't included in topic subscriptions for which they weren't intended.
Wildcard Examples
The following table provides examples of topic subscription matches when using wildcards.
Wildcard Subject | Matches Messages With Subjects Like: | Does Not Match Messages With Subjects Like: |
---|---|---|
animals/domestic/*
|
animals/domestic/cats
animals/domestic/dogs
|
animals/domestic/dogs/beagles
|
animals/*/cats/*
|
animals/domestic/cats/persian
|
animals/domestic/cats/persian/grey
|
animals/domestic/dog*
|
animals/domestic/dog
|
animals/domestic/dog/beagle
|
animals/domestic/>
|
animals/domestic/cats
|
animals
|
animals/*/cats/>
|
animals/domestic/cats/tabby/grey
|
animals/domestic/dogs/beagles
|
my/test/*
|
my/test/topic
|
My/Test/Topic
|