1.3. Topic Exchange

1.3. Topic Exchange

A Topic exchange is similar to a Direct exchange, but it supports multipart keys that contain multiple words separated by the “.” delimiter; for instance, a message producer can create messages with routing keys like usa.news, usa.weather, europe.news, and europe.weather. Binding keys can include wildcard characters: a “#” matches one or more words, a “*” matches a single word. Typical bindings use binding keys like #.news (all news items), usa.# (all items in the USA), or usa.weather (all usa weather items). The exchange routes messages to the relevant queue or queues, depending on matches between the routing and binding keys.

Topic Exchange

A Topic exchange can use multi-part routing keys and bindings that include wildcards. A topic exchange sends a message to a queue if the message's routing key matches the binding key for the queue, using wildcard matching.