This example demonstrates the use of multi-part keys in a topic exchange
A message producer creates four messages concerning news and weather in the United States of America and Europe. The producer creates four different routing keys for the messages, each of which contains two parts. The two parts of the routing keys are separated with a
. (period) character:
usa.news
usa.weather
europe.news
europe.weather
There are currently four queues bound to the topic exchange. The four queues collect information on:
Everything related to the USA
All news
All weather
Everything related to Europe
These are defined as a two-part binding key, with the
# (pound) character as a wildcard:
usa.#
#.news
#.weather
europe.#
So, in this example, the message with the routing key of usa.weather will be delivered to two queues - usa.# and #.weather. Similarly, the message with the routing key of europe.news will be delivered to the queues with the binding keys europe.# and #.news