Introduction to RabbitMQ

Reading Time: 3 minutes

The world is a stage where all of us are artists. Constant learning is the foundation of success. So here we are going to learn about an open-source message broker technology which is RabbitMQ.

Overview

RabbitMQ is the open-source message broker software that uses AMQP to transfer data. i.e, RabbitMQ accepts messages from producers and delivers them to consumers. So, RabbitMQ is like a middleman which is used to reduce loads and delivery times taken by web application servers. It gives your applications a common platform to send and receive messages, and your messages a safe place to live until received.

About AMQP

AMQP is Advanced Message Queuing Protocol which is a messaging protocol that enables conforming client applications to communicate with conforming messaging middleware brokers.
Messaging brokers receive messages from publishers and route them to consumers.
AMQP has Queues, exchanges, and bindings which are collectively referred to as its entities. These entities help us to translate messages from producer to consumer.

RabbitMQ Components

RabbitMQ comes with the following 4 basic components:
– Producer
– Exchange
– Queue
– Consumer

Producer

Producing means nothing more than sending. A program that sends messages is a producer.
We Send our message from the publisher. The publisher will connect to RabbitMQ, send a single message, then exit.

When publishing a message, publishers may specify various message attributes (message meta-data). Some of these attributes can be consumed by RabbitMQ(broker) but many will be only consumed by the Receiver.

Exchange

Broker has two components: Exchange and Queue.

Exchanges take a message from the producer and route it into zero or more queues. The routing algorithm used depends on the exchange type and rules called bindings.
There are the following types of exchange type:

– Direct exchange: When we have to send messages to queue only when specific key’s(routing key) value matches between them.

– Fanout exchange: When we want to broadcast our message So that any queue can receive the message.

– Topic exchange: Unlike Direct exchange, they match pattern instead of an exact key.

– Headers exchange: The value of the header equals the value specified upon the routing key.

Queue

A queue is message storage which is found in RabbitMQ. Although messages flow through RabbitMQ and your applications, they can only be stored inside a queue.
queue is only bound by the host’s memory & disk limits. It is essentially a large message buffer. Many producers can send messages that go to one queue, and many consumers can try to receive data from one queue.

Before a queue can be used it has to be declared. Declaring a queue will cause it to be created if it does not already exist. The declaration will have no effect if the queue does already exist and its attributes are the same as those in the declaration. 

Receiver

Consuming has a similar meaning to receiving. A consumer is a program that mostly waits to receive messages. Our consumer listens for messages from RabbitMQ.  
In order to consume messages, there has to be a queue. When a new consumer is added, assuming there are already messages ready in the queue, deliveries will start immediately.

Advantages of RabbitMQ

  • Asynchronous Messaging:
    Supports multiple messaging protocols, message queuing, delivery acknowledgement, flexible routing to queues, multiple exchange type.
  • Developer Experience:
    Deploy with Docker and Puppet etc. Develop with favourite programming languages such as: Java, PHP, Python, JavaScript, and many others.
  • Distributed Deployment:
    Federate across multiple availability zones and regions; deploy as clusters for high availability and throughput.
  • Enterprise & Cloud Ready:
    Authorisation, supports TLS and LDAP, pluggable authentication. Lightweight and easy to deploy in public and private clouds.
  • Tools & Plugins:
    Diverse array of tools and plugins supporting continuous integration, operational metrics, and integration to other enterprise systems. Flexible plug-in approach for extending RabbitMQ functionality.
  • Management & Monitoring:
    UI, command line tool, and HTTP-API for managing and monitoring RabbitMQ

That’s pretty much it from the article. If you have any feedback or queries, please do let me know in the comments. Also, if you liked the article, please give me a thumbs up and I will keep writing blogs like this for you in the future as well. Keep reading and Keep coding.

Reference

Written by 

I am a genius middle-class noble philanthropist(by heart) . & Simply a technology enthusiast who loves to share and gain knowledge through blogs.