RabbitMQ three kinds Exchange Mode (fanout, direct, topic) performance comparison

RabbitMQ three kinds Exchange Mode (fanout, direct, topic) performance comparison

一.Direct Exchange

0ec0f465-49c6-361c-ae2b-dd951a6ed1a9

Direct Exchange to send any message will be forwarded to RouteKey specified Queue.

1. General use rabbitMQ comes Exchange: "" (the name is an empty string Exchange, hereinafter referred to as default Exchange).

The binding does not require any Exchange (Binding) 2. Operation in this mode

Requires a "RouteKey" 3. messaging, it can be simply understood as the name of the queue to be sent.

4. If the queue name does not exist RouteKey vhost specified, then the message will be discarded.

 

二.Fanout Exchange 

0bbdcd3d-9fc6-3107-b7e0-db67c174d46a

 

Any messages sent to Fanout Exchange will be forwarded to all the Exchange Queue bindings (Binding) of.

1. The pattern can be understood as a routing table

2. This mode does not require RouteKey

3. This model requires advance with the Exchange Queue bind, you can bind more than one Exchange Queue, Queue can be bound with a multiple Exchange.

4. If the received message and Exchange does not bind any Queue, then the message will be discarded.

 

三.Topic Exchange

11171ab4-af07-3ff6-bdf6-d1febda679c3

 

Any messages sent to the Topic Exchange will be forwarded to all concerned RouteKey specified topics Queue

1. This model is more complex, in simple terms, is that each queue has its own theme concerned, all messages are presented with a "Title" (RouteKey), Exchange will forward the message to all concerned topics can blur and RouteKey matching queue.

2. This model requires RouteKey, perhaps to bind the Exchange Queue advance.

3.在进行绑定时,要提供一个该队列关心的主题,如“#.log.#”表示该队列关心所有涉及log的消息(一个RouteKey为”MQ.log.error”的消息会被转发到该队列)。

4.“#”表示0个或若干个关键字,“*”表示一个关键字。如“log.*”能与“log.warn”匹配,无法与“log.warn.timeout”匹配;但是“log.#”能与上述两者匹配。

5.同样,如果Exchange没有发现能够与RouteKey匹配的Queue,则会抛弃此消息。

 http://hwcrazy.com/2a31095868c811e3ad76000d601c5586/group/free_open_source_project/

一.Direct Exchange

0ec0f465-49c6-361c-ae2b-dd951a6ed1a9

任何发送到Direct Exchange的消息都会被转发到RouteKey中指定的Queue。

1.一般情况可以使用rabbitMQ自带的Exchange:”"(该Exchange的名字为空字符串,下文称其为default Exchange)。

2.这种模式下不需要将Exchange进行任何绑定(binding)操作

3.消息传递时需要一个“RouteKey”,可以简单的理解为要发送到的队列名字。

4.如果vhost中不存在RouteKey中指定的队列名,则该消息会被抛弃。

 

二.Fanout Exchange 

0bbdcd3d-9fc6-3107-b7e0-db67c174d46a

 

任何发送到Fanout Exchange的消息都会被转发到与该Exchange绑定(Binding)的所有Queue上。

1.可以理解为路由表的模式

2.这种模式不需要RouteKey

3.这种模式需要提前将Exchange与Queue进行绑定,一个Exchange可以绑定多个Queue,一个Queue可以同多个Exchange进行绑定。

4.如果接受到消息的Exchange没有与任何Queue绑定,则消息会被抛弃。

 

三.Topic Exchange

11171ab4-af07-3ff6-bdf6-d1febda679c3

 

Any messages sent to the Topic Exchange will be forwarded to all concerned RouteKey specified topics Queue

1. This model is more complex, in simple terms, is that each queue has its own theme concerned, all messages are presented with a "Title" (RouteKey), Exchange will forward the message to all concerned topics can blur and RouteKey matching queue.

2. This model requires RouteKey, perhaps to bind the Exchange Queue advance.

3. When making binding, to provide a topic of concern to the queue, such as "# .log. #" Indicates that the queue care of all the messages involved in log (a RouteKey as "MQ.log.error" message will be forwarded to the queue).

4. "#" Represents 0 or several keywords, "*" indicates a keyword. As ". Log *" can match "log.warn", can not match the "log.warn.timeout"; but ". Log #" to match with both.

5. Similarly, if Exchange is not found possible to match the RouteKey Queue, this message will be discarded.

 http://hwcrazy.com/2a31095868c811e3ad76000d601c5586/group/free_open_source_project/

Guess you like

Origin www.cnblogs.com/tellerfuliye/p/12034314.html