Using Wildcards to Receive Related Subjects

Programs can listen for wildcard subject names to access a collection of related data through a single subscription.

The asterisk (*) is a wildcard character that matches any one element. The asterisk substitutes for whole elements only, not for partial substrings of characters within an element.

Greater-than (>) is a wildcard character that matches all the elements remaining to the right.

A listener for a wildcard subject name receives any message whose subject name matches the wildcard.

The following examples illustrate wildcard syntax and matching semantics.

Semantics of Listening to Wildcard Subjects

Listening to this wildcard name

Matches messages with names like these:

But does not match messages with names like these (reason):

RUN.*

RUN.AWAY

RUN.away

RUN.Run.run (extra element)

Run.away (case)

RUN (missing element)

Yankees.vs.*

Yankees.vs.Red_Sox

Yankees.vs.Orioles

Giants.vs.Yankees (position)

Yankees.beat.Sox (vs¹beat)

Yankees.vs (missing element)

*.your.*

Amaze.your.friends

Raise.your.salary

Darn.your.socks

your (missing elements)

Pick.up.your.foot (position)

RUN.>

RUN.DMC

RUN.RUN.RUN

RUN.SWIM.BIKE.SKATE

HOME.RUN (position)

Run.away (case)

RUN (missing element)

Invalid Wildcard Subject Examples

Invalid Wildcards

Reason

abc*xyz

Asterisk (*) must take the place of one whole element, not a substring within a element.

Foo.>.baz

Greater-than (>) can only appear as the right-most character.

Wildcard Sending

Warning 

It is good practice to avoid sending messages to wildcard subject names. Although transports do not prevent you from sending to wildcard subjects, doing so can trigger unexpected behavior in other programs that share the network.

For example, wildcard subjects can often be broader than intended, so that unrelated applications might receive messages that they cannot parse.

It is illegal for certified delivery transports to send to wildcard subjects. It is illegal to send to distributed queues using wildcard subjects.