Wildcards
In Apache ActiveMQ, wildcards are used to match multiple destinations (queues or topics) using patterns, instead of specifying each one explicitly. This concept has been popular in financial market data for some time as a way of organizing events (such as price changes) into hierarchies and to use wildcards for easy subscription of the range of information you're interested in.
For example imagine you are sending price messages from a stock exchange feed. You might use some kind of destination such as
• PRICE.STOCK.NASDAQ.ORCL to publish Oracle Corporation's price on NASDAQ and
• PRICE.STOCK.NYSE.IBM to publish IBM's price on the New York Stock Exchange
A subscriber could then use exact destinations to subscribe to exactly the prices it requires. Or it could use wildcards to define hierarchical pattern matches to the destinations to subscribe from.
Composite Destinations
ActiveMQ supports composite destinations that allow a single virtual JMS Destination to be used to represent a collection of JMS Destinations.
For example you can use composite destinations to send a message to 12 physical queues in one operation. Or send a message to one topic and one queue in one operation.
Composite destinations can also be configured on the broker side, such that messages sent to a single destination by the client will be transparently copied to multiple physical destinations.
What are ActiveMQ Wildcards?
Wildcards let you:
• Subscribe to or manage multiple destinations using a pattern-based name
• ActiveMQ uses a hierarchical naming system, where destinations are separated by.
Example:
• Orders.Europe.France
• Orders.Europe.Germany
• Orders.Asia.Japan
Wildcard Symbols
1. * (Single-level wildcard)
Matches exactly one level
Orders.*.France
Matches:
• Orders.Europe.France
• Orders.Asia.France
• Orders.France (missing level)
• Orders.Europe.Paris.France (too deep)
2. > (Multi-level wildcard)
Matches one or more levels (everything after a point)
Orders.Europe.>
Matches:
• Orders.Europe.France
• Orders.Europe.Germany.Berlin
• Orders.Europe.UK.London.Store1
Use Cases of Wildcards
1. Flexible Subscriptions
Instead of subscribing to 100 topics: Orders.Europe.*
2. Multi-region Systems
• Orders.US.*
• Orders.EU.*
3. Monitoring / Logging
Subscribe to: ActiveMQ.Advisory.>
4. Security Rules
Grant access like:
• Allow: Orders.Europe.*
• Deny: Orders.Admin.>
Key Features
• Hierarchical matching
• Supports both queues and topics
• Works in broker configs and client subscriptions
• Enables dynamic systems (no hardcoding)
Advantages
Scalability
No need to define every destination
Flexibility
Easily adapt to new destinations
Cleaner Configuration
Less duplication in configs
Dynamic Routing
Works well with large distributed systems
Disadvantages
Overmatching Risk
A pattern like: Orders.>
may consume more than intended
Harder Debugging
Wildcard subscriptions can make it unclear: Where messages are going
Performance Impact
Very broad wildcards may: Increase broker workload