Introduction of various exchange types of RabbitMQ Exchange Types

The latest version of RabbitMQ has four exchange types, namely Direct exchange, Fanout exchange, Topic exchange, and Headers exchange.

 

Direct Exchange  - handles routing keys. A queue needs to be bound to an exchange, requiring the message to exactly match a specific routing key. This is a complete match. If a queue is bound to this switch and requires the routing key "dog", only messages marked with "dog" will be forwarded, neither dog.puppy nor dog.guard will be forwarded, only dog. 


 

 

 

Fanout Exchange  - Does not process routing keys. You simply bind the queue to the exchange. A message sent to an exchange is forwarded to all queues bound to the exchange. Much like subnet broadcasts, hosts on each subnet get a copy of the message. Fanout switches are the fastest to forward messages. 

Topic Exchange  - Match routing keys to a pattern. At this point the queue needs to be bound to a schema. The symbol "#" matches one or more words, and the symbol "*" matches no more than one word. So "audit.#" would match "audit.irs.corporate", but "audit.*" would only match "audit.irs". My friend at RedHat made a nice diagram to show how the topic switch works: 

Note: In this case, the queue will receive messages that conform to the topic rules from all routers

 

Headers exchange  - Ignore, no applied research.

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326240063&siteId=291194637