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.
|
Listening to this wildcard name |
Matches messages with names like these: |
But does not match messages with names like these (reason): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Invalid Wildcards |
Reason |
|
|
Asterisk ( |
|
|
Greater-than ( |
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. |