该交换器,可以使得来自不同源头的消息能够到达同一队列。通过在队列绑定时,通过不同位置和类型的通配符来实现。
Topic exchange can’t have an arbitrary routing_key, it must be a list of words,delimited by dots. Routing key example:”stock.usd.nyse”, “nyse.vmw”, “quick.orange.rabbit”. There can bu as many words in the routing key as you like,up to the limit of 255bytes.
Two cases for binding keys:
*(star) can substitute for exactly one word.
#(hash) can sbustitute for zero or more words.
If we break our contract and send a message with one or four words,like “orange” or “quick.orange.male.rabbit”, these messages won’t match any bindings and will be be lost.
On the other hand “lazy.orange.male.rabbit”, even though it has four words, will match the queue “lazy.#” and will be delivered to the second queue.
把msg-inbox模块的error , info , warnning logs投递到msg-inbox-log 队列
$channel -> queue_bind(‘msg-inbox-log’, ‘logs-exchange’, ‘*.msg-inbox’)
All-log队列将会接收所有从web应用程序发布的所有日志
$channel -> queue_bind(‘all-log’, ‘logs-exchange’, ‘#’)