RabbitMQ switch type (c)

 

There are four types RabbitMQ switch, depending on its route is divided into the process

They are Direct Exchange (direction switch), Fanout Exchange (fan-shaped switch), Topic Exchange (theme switch) with Headers Exchange (head switch)

The following are four kinds of switches route map and explain,

 

Direct Exchange (direction switch): the named message queue Q and D are called a direct route through the switch key is bound to R, when the direction switch to send a routing keys Msg and R when the D, D will Msg direction switch to the distributed queue Q according to the routing key R. This model is similar to one

 


 Fanout Exchange (fan switch): Msg when a sector is sent to the switch F, then F fan switch sends the message to all the bindings are sent to the message queue F. Sector switch to route messages to bind to all its message queue, i.e. no routing key role in the switch in the sector, message queues so that when binding the fan switch, routing keys may be empty. This mode is similar to a broadcast.

 


Topic Exchange (theme switch): topic switch is a publish / subscribe model combines the characteristics of direct-connect switch and fan switch, binding and subject of the message queue routing through the switch is key. When sending a routing keys Msg and rules relating to a switch T, T will be screened in accordance with routing keys conform to the rules of the rules bound to their queue message routing keys (which may be one, or it may be the N, may It is 0), according to the route matching key, sends the message to its corresponding message queue. This mode is similar to multicasting, when the message routing rules only match to a routing keys, then switch the topic can be seen as direct-connect switch, when the routing rule matches all queue routing switch key bindings on the theme of time, At this theme can be seen as a fan switch switch

 


 Headers Exchange(头交换机):头交换机类似与主题交换机,但是却和主题交换机有着很大的不同。主题交换机使用路由键来进行消息的路由,而头交换机使用消息属性来进行消息的分发,通过判断消息头的值能否与指定的绑定相匹配来确立路由规则。在头交换机里有一个特别的参数”x-match”,当”x-match”的值为“any”时,只需要消息头的任意一个值匹配成功即可,
当”x-match”值为“all”时,要求消息头的所有值都需相等才可匹配成功。虽然至今没有遇到过头交换机,但是还是建议各位同学去了解一下。

以上如有问题,欢迎指正

下一篇:PHP中RabbitMQ之amqp扩展实现(四)

下一篇:PHP中RabbitMQ之phpAmqplib实现(五)

 

Guess you like

Origin www.cnblogs.com/php-linux/p/11293881.html