2018-03-08 15:46:38 -05:00
|
|
|
# Wildcard Syntax
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
Apache ActiveMQ Artemis uses a specific syntax for representing
|
|
|
|
wildcards in security settings, address settings and when creating
|
|
|
|
consumers.
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2017-12-22 16:25:21 -05:00
|
|
|
The syntax is similar to that used by [AMQP](https://www.amqp.org).
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
An Apache ActiveMQ Artemis wildcard expression contains **words
|
|
|
|
separated by a delimiter**. The default delimiter is `.` (full stop).
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2022-01-22 01:16:50 -05:00
|
|
|
The special characters `#` and `*` also have special meaning and can
|
2023-04-26 13:50:21 -04:00
|
|
|
take the place of a **word**.
|
|
|
|
|
|
|
|
To be clear, the wildcard characters cannot be used like wildcards in
|
|
|
|
a [regular expression](https://en.wikipedia.org/wiki/Regular_expression).
|
|
|
|
They operate exclusively on **words separated by a delimiter**.
|
|
|
|
|
|
|
|
## Matching Any Word
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2022-01-22 01:16:50 -05:00
|
|
|
The character `#` means "match any sequence of zero or more words".
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
So the wildcard `news.europe.#` would match:
|
|
|
|
- `news.europe`
|
|
|
|
- `news.europe.sport`
|
|
|
|
- `news.europe.politics`
|
|
|
|
- `news.europe.politics.regional`
|
|
|
|
|
|
|
|
But `news.europe.#` would _not_ match:
|
|
|
|
- `news.usa`
|
|
|
|
- `news.usa.sport`
|
|
|
|
- `entertainment`
|
|
|
|
|
|
|
|
## Matching a Single Word
|
|
|
|
|
2022-01-22 01:16:50 -05:00
|
|
|
The character `*` means "match a single word".
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
The wildcard `news.*` would match:
|
|
|
|
- `news.europe`
|
|
|
|
- `news.usa`
|
|
|
|
|
|
|
|
But `news.*` would _not_ match:
|
|
|
|
- `news.europe.sport`
|
|
|
|
- `news.usa.sport`
|
|
|
|
- `news.europe.politics.regional`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
The wildcard `news.*.sport` would match:
|
|
|
|
- `news.europe.sport`
|
|
|
|
- `news.usa.sport`
|
2014-12-04 10:25:29 -05:00
|
|
|
|
2023-04-26 13:50:21 -04:00
|
|
|
But `news.*.sport` would _not_ match:
|
|
|
|
- `news.europe.politics`
|
2016-12-23 06:02:30 -05:00
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
## Customizing the Syntax
|
2016-12-23 06:02:30 -05:00
|
|
|
|
|
|
|
It's possible to further configure the syntax of the wildcard addresses using the broker configuration.
|
|
|
|
For that, the `<wildcard-addresses>` configuration tag is used.
|
|
|
|
|
2018-03-08 15:46:38 -05:00
|
|
|
```xml
|
|
|
|
<wildcard-addresses>
|
|
|
|
<routing-enabled>true</routing-enabled>
|
|
|
|
<delimiter>.</delimiter>
|
|
|
|
<any-words>#</any-words>
|
|
|
|
<single-word>*</single-word>
|
|
|
|
</wildcard-addresses>
|
|
|
|
```
|
2016-12-23 06:02:30 -05:00
|
|
|
|
|
|
|
The example above shows the default configuration.
|