Featured Post

Event Sourcing Video from Michael Ploed

Event Sourcing I want to share a great video I found few days ago that describes very well what Event Sourcing is.

Wednesday, February 7, 2018

RabbitMQ Exchange


RabbitMQ has the concept of Exchange: "messages are not published directly to a queue, instead, the producer sends messages to an exchange".
The Exchange is therefore responsible for the routing of the messages to different queues. It uses. The Routing Key (message attribute) in order to decide how to route the message to queues.

Roting Key

  • The Routing key is a message attribute in the message header sent by the producer.
  • The Routing Key can be a list of words delimited by a period:  robotics.us , robotics.eu.model.

Exchange Types

There are four types of exchange:

  1. Direct Exchange:  a message goes to a queue  if the binding key exactly matches the routing key of the message;
  2. Topic Exchange: a message is queued based on wildcard matches between the routing key and a routing pattern specified by the queue binding. Messages are routed to one or many queues. Each consumer declares which topics they are interested in with a binding that gives a routing pattern to the exchange. 
  3. Fanout Exchange: a message is copied and routed to all queues that are bound to it regardless of routing keys or pattern matching;
  4. Header Exchanges: a message is routed based on arguments contained int the headers and optional values instead of routing keys.



No comments :

Post a Comment