This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8397|Reply: 0

Introduction to the three exchange modes (fanout, direct, and topic) of RabbitMQ

[Copy link]
Posted on 3/29/2018 2:30:45 PM | | | |
Introduction:
In RabbitMQ, all messages submitted by producers are accepted by Exchange, which then forwards them to Queue for storage according to a specific policy
RabbitMQ provides four types of exchanges: fanout, direct, topic, and header
The header mode is less used in practice, and this article only compares the first three modes.

1. Direct Exchange


Any messages sent to Direct Exchange are forwarded to the Queue specified in the RouteKey.

1. In general, you can use the Exchange that comes with rabbitMQ:" (the name of the Exchange is an empty string, hereinafter referred to as the default Exchange).

2. In this mode, there is no need to perform any binding operations on Exchange

3. A "RouteKey" is required for messaging, which can be simply understood as the name of the queue to be sent to.

4. If the queue name specified in the RouteKey does not exist in the vhost, the message is dropped.

2. Fanout Exchange


Any messages sent to the Fanout Exchange are forwarded to all Queues bound to that Exchange.

1. It can be understood as a pattern of the routing table

2. This mode does not require a RouteKey

3. This mode requires binding Exchange to Queue in advance, one Exchange can bind multiple Queues, and one Queue can be bound to multiple Exchanges.

4. If the Exchange that received the message is not bound to any Queue, the message is dropped.

3. Topic Exchange


Any messages sent to the Topic Exchange are forwarded to all Queues that care about the topics specified in the RouteKey

1. This pattern is more complex, simply put, each queue has its own topic of concern, all messages have a "title" (RouteKey), and Exchange will forward the message to all queues that can fuguely match the RouteKey of the topic of concern.

2. This mode requires a RouteKey, perhaps binding Exchange and Queue in advance.

3. When binding, provide a topic that the queue cares about, such as "#.log.#" to indicate that the queue cares about all messages related to logs (a message with a RouteKey of "MQ.log.error" will be forwarded to the queue).

4. "#" means 0 or several keywords, and "" means one keyword. For example, "log." It can match "log.warn", but cannot match "log.warn.timeout"; But "log.#" matches the above.

5. Similarly, if Exchange does not find a Queue that matches the RouteKey, it will drop this message.




Previous:Use XPosed to bypass strong validation of Android SSL certificates
Next:.net/c# RabbitMQ connection disconnection - disconnection and reconnection
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com