Components of a Messaging Architecture with RabbitMQ

We’ll outline the components of a Messaging Architecture based on RabbitMQ. We would examine terms including: Producer, Consumer, Exchanger, Routing Key, Binding etc.

See tutorial on how to setup RabbitMQ.

RabbitMQ Video Tutorial here

 

Producer

in the context of microservices, this is the service that creates a message and publishes it to the message broker

 

Consumer

this is the service or application the receives a message from the message broker. It is also important to note that the same client application can play the role of both the producer and consumer depending on the scenario. For example, if the client creates and sends a message to the queue, then it is a producer at that point. However, when the same client gets a response back from the message broker, then it’s role switches to that of a consumer

 

Connection

this is a TCP/IP network that handles communication between the producer and consumer via the message broker. The connection tab in RabbitMQ indicates the current connections to the nodes.

Connection tab in RabbitMQ
Connection tab in RabbitMQ

 

Channel

A channel is a stream of communication from one point to another. It could be either from producer to the message queue or from the message queue to the consumer. The figure below shows the channel available in my little experiment!

Channels in RabbitMQ
Channels in RabbitMQ

 

Exchange

This is the component responsible for receiving messages from producers and routing them to the consumer. Similar to the telephone exchange for call routing, when messages arrive the exchange, it determines the target consumer for particular message and routes accordingly. Clicking the exchanges tab would show the exchanges as shown below. Four types of exchanges in RabbitMQ include

  • Topic
  • Fanout
  • Direct
  • Headers
Exchanges in RabbitMQ
Exchanges in RabbitMQ

 

Message

This is the information to be transmitted. A message is made up of two parts: the header and the body. The header contains the message properties and other information while the body contains the specific application data. The message body is also called the payload. A message can have the following properties:

  • Published
  • Unacknowledged
  • Redelivered
  • Acknowledged
  • Ready
  • Received

 

Queue

This is the component that hold the messages sent by the producer. Messages are held in a FIFO pattern and delivered to the consumers from the queue.

 

Routing Key

How does the exchange know the destination of an incoming message? It uses the routing key which is a virtual address that specifies how the message is to be routed. Sometimes, there may be multiple queues and the routing key is used to determine the particular target queue.

 

Binding

A binding is a connection for that relates an exchange to a queue. The figure below shows a binding between the exchange SAMPLE_EXCHANGE to the queue remoting.queue

Binding in RabbitMQ
Binding in RabbitMQ

Cluster and Nodes

Sometimes you may have to create a cluster in RabbitMQ. A cluster is made up of one or more nodes where a node is an instance of RabbitMQ server. I will make a tutorial on how to create a RabbitMQ cluster in coming days in my YouTube Channel.

 

Admin bar avatar

kindsonthegenius

Kindson Munonye is currently completing his doctoral program in Software Engineering in Budapest University of Technology and Economics

View all posts by kindsonthegenius →

Leave a Reply

Your email address will not be published. Required fields are marked *