官术网_书友最值得收藏!

Direct exchange

A direct exchange delivers messages to queues based on a message routing key. The routing key can be seen as an address that the exchange is using to decide how to route the message. A message goes to the queues whose binding key exactly matches the routing key of the message.

The direct exchange type is useful when you would like to distinguish messages published to the same exchange using a simple string identifier.

Imagine that Queue A (create_pdf_queue) in the following diagram is bound to a direct exchange (pdf_events) with the binding key pdf_create. When a new message with the routing key pdf_create arrives at the direct exchange, the exchange routes it to the queue where the binding_key = routing_key is, in this case, to Queue A (create_pdf_queue).

SCENARIO 1:

  • Exchange: pdf_events
  • Queue A: create_pdf_queue
  • Binding a key between exchange (pdf_events) and Queue A (create_pdf_queue): pdf_create

SCENARIO 2:

  • Exchangepdf_events
  • Queue B: pdf_log_queue
  • Binding a key between exchange (pdf_events) and Queue B (pdf_log_queue): pdf_log

EXAMPLE:

 A message with the routing key pdf_logis sent to the exchange pdf_events. The message is routed to pdf_log_queue because the routing key (pdf_log) matches the binding key (pdf_log). If the message routing key does not match any binding key, the message will be discarded, as seen in the direct exchange diagram:

 A message goes to the queues whose binding key exactly matches the routing key of the message.

主站蜘蛛池模板: 应城市| 长岛县| 富源县| 六枝特区| 博客| 邢台县| 赤城县| 石家庄市| 通城县| 潍坊市| 昔阳县| 泰来县| 舒城县| 漳平市| 肥东县| 凤凰县| 邵东县| 磐安县| 阿拉善右旗| 湖州市| 申扎县| 鹤壁市| 保山市| 克拉玛依市| 岚皋县| 高雄市| 宜兴市| 安远县| 宜昌市| 合阳县| 龙胜| 海口市| 西乌| 张北县| 松江区| 东乡县| 忻州市| 图们市| 佛冈县| 井冈山市| 南雄市|