direct exchange can't do routing based on multiple criteria. eg, in our logging system we might want to subscribe to not only logs based on severity, but also based on the source which emitted the log
Topics: Receiving messages based on a pattern
Topic Exchange: Messages sent to a topic exchange can't have an arbitrary routing_key - it must be a list of words, delimited by dots. The words can be anything, but usually they specify some features connected to the message.
Eg:
- stock.usd.nyse
- quick.orange.rabbit
binding Keys: a message sent with a particular routing key will be delivered to all the queues that are bound with a matching binding key.
* (star) can substitute for exactly one word.
# (hash) can substitute for zero or more words.
Screen Shot 2020-07-22 at 4.16.01 PM
We created three bindings:
Q1 is bound with binding key ".orange." and Q2 with "..rabbit" and "lazy.#".
Q1 is interested in all the orange animals.
Q2 wants to hear everything about rabbits, and everything about lazy animals.
quick.orange.rabbit deliver to both; quick.orange.fox goes to first; lazy.brown.fox (or lazy.orange.male.rabbit) goes to second. If NO matching found msg will be lost.
When queue bound with #, receive all msg regardless of routing key, simiar to fanout when queue bound with exact world (no # or * ), topic exchange behave like direct