RabbitMQ – Robust Way of Messaging for Application

Messaging allows software applications to connect and scale. Different applications can connect to each other, as components of a larger application through messaging.

You might be thinking, how this messaging between different applications can be actually achieved and what is the best way of exchanging data between processes, applications, and servers?

Well, if you ask me then the answer is “RabbitMQ”.

RabbitMQ is open source message broker software. The principal idea is pretty simple: it accepts and forwards messages.

RabbitMQ is the most popular open-source implementation of the AMQP (Advanced Message Queuing Protocol) messaging protocol, written in “Erlang” that you can access from any language.

It is software where queues are defined; application binds and listens to these queues and transfer messages from it.

Basic architecture of a message broker is simple, there are client applications called producers that create messages and deliver them to the broker. Other applications, called consumers, connects to the queue, subscribes and gets the messages. Software can be either a producer, or consumer, or both. Messages placed onto the queue are stored until the consumer retrieves them.

RabbitMQ-1

Where,

  • P – Producer, sends message to queue
  • C – Consumer, waits to receive messages from queue
  • queue – Queue (Message Broker)

A queue is the name for a mailbox. It lives inside RabbitMQ, although messages flowing through RabbitMQ and your applications can be stored only inside a queue. There is no limit for the queue; it can store as many messages as you want. Essentially it’s an infinite buffer. You can have many producers to send messages to one queue or many consumers can try to receive data from one queue.

Ideally, producer, consumer, and broker don’t have to reside on the same machine; however in most applications they don’t.

In order to make sure that, messages from producers go to right consumer, RabbitMQ broker uses two key components: Exchanges and Queues

So, just to be clear, messages in RabbitMQ are not published directly to queue, instead producer sends message to an entity called “Exchange”. Exchanges are like message routing agents.

Below diagram will help you to understand, where these entities stands in RabbitMQ:

RabbitMQ-2

The exchange is responsible for the routing the messages to the different queues. An exchange accepts messages from the producer application and routes them to message queues with the help of bindings and routing keys. A binding is the link between a queue and an exchange.

Ideally, RabbitMQ server setup contains multiple queues (one per consumer) as follow:

RabbitMQ-3

Here, C1, C2, C3, C4 are consumers, Q1, Q2, Q3, Q4 – are queue names which are bind with  C1, C2, C3, C4 respectively.

We can also have more than one exchange and with different name in single RabbitMQ setup. Usually, the publisher or consumer creates the exchange with a given name and then send it to known clients.

Now, you might be thinking of how messages actually routed from exchange to appropriate queue?

First, a consumer/producer (typically consumer) creates a queue and attaches it to an exchange with a specific routing key. This process is called as binding.

Basically, each queue is attached with exchange with different routing key.

Before understanding further flow, we need to understand structure of an AMQP message:

Each message sent through RabbitMQ is having following format-

RabbitMQ-4

First two fields, the headers and properties of the message are basically key/value pairs.

  • Headers – Defined by the AMQP specification
  • Properties – Contain application-specific information.
  • Bytes [] data – Actual message content.

Now, as you have understood the RMQ message structure, let’s come back to binding concept.

Each message header contains “routing-key”. This routing key is used to identify its appropriate queue. Each consumer keeps listening on queue and these queues are attached to Exchange with specific binding key.

So whenever exchange gets message from producer, message broker finds “routing-key” from message header and compares with each queue’s binding key. And finally message is sent to queue which matches its binding key with message header “routing-key”. And respective consumer who is listening to this queue gets message and starts processing. That’s it J

There are 4 types of exchanges based on, how binding key matches with routing key.

Sr.No. Exchange Type Behavior
1 Direct Exchange The binding key must match the routing key exactly – no wildcard support
2 Topic Exchange Same as Direct, but wildcards are allowed in the binding key. ‘#’ matches zero or more dot-delimited words
3 Fanout Exchange The routing and binding keys are ignored – all published messages go to all bound queues.
4 Header Exchange Headers exchanges use the message header attributes for routing.

You can install the RabbitMQ on your host machine and play with its management UI webpage using link- “https://<host-ip>:555672”

<host-ip> is the one where you have installed RabbitMq client.

At the last, let me tell you few reasons that will probably make RabbitMQ best choice-

    1. Decoupling: One of the main requirements for software development is to have decoupled components in it. This can be easily done using RabbitMQ.
    2. Scalability: By using RabbitMQ, we can allow producer to transmit a message/task/command for processing to unlimited number of consumers. Before this make sure that, you have already created new message consumers.
    3. Flexibility: Using RabbitMQ (which uses AMQP protocol), we can easily connect or allow to communicate two totally different applications (can be written on different languages) together.
    4. Many Clients: There are RabbitMQ client’s supports for almost any language you can think of.

[Tweet “RabbitMQ – Robust Way of Messaging for Application ~ via @CalsoftInc”]

 
Share:

Related Posts

Unlocking Network Agility Open RAN and the Future of Service Management & Orchestration (SMO)

Unlocking Network Agility: Open RAN and the Future of Service Management & Orchestration (SMO)

Recently, Open RAN turned out to be a transformative and innovative solution in the telecom industry. Service Management Orchestration (SMO) serves at the core of this transformative solution, revolutionizing the way mobile networks are deployed and managed. SMO in Open RAN framework foster openness, flexibility, interoperability supporting multi-vendor and cost-effective network deployments. SMO is paving the way for a new era of wireless connectivity, shaping the future of Open RAN deployments. Read the blog to explore the significance of SMO platform in Open RAN framework.

Share:
Technical Documentation

Technical Documentation Review and Tips

Technical reviews are vital for effective and quality documentation. To make this happen, have documentation and its reviews listed as one of the deliverables – just like development or testing. This will place priority on the process, and ensure everyone involved understands the importance of proper and thorough reviews.

Share:
Importance of System Integration in Next-Generation Telecom Networks

Importance of System Integration in Next-Generation Telecom Networks

The telco sector is evolving, and the significance of system integration cannot be overplayed in the industry. The next-generation networks are ever more complex, including diverse technologies like 5G, IoT, cloud computing, and more. To ensure reliable and high-quality services, seamless system integration becomes the cornerstone. Integration ensures that distinct components and services work harmoniously, stimulating efficient communication and streamlined operations. It facilitates the interconnectivity of various subsystems, enabling real-time data exchange, advanced service delivery, and enhanced end-user experiences. Read the blog to explore the significance of system integrators in telecom industry.

Share:
5G Transport Architecture xHaul Transport

5G Transport Architecture: xHaul Transport

The telecom industry is witnessing a rapid network transformation, enabled by a wide range of pioneering technology trends. The network transformation is towards a virtualized, software defined, flexible, and open framework to support next generation 5G use cases. To effectively realize a high quality 5G user experience, future transport networks will play a crucial role to meet service requirements such as peak data rates, maximum coverage, ultra-low latency, synchronization, and security. Read the blog to explore 5G transport technologies and the key advancements in 5G transport architecture.

Share:
Technology Trends 2024

Technology Trends 2024- The CXO perspective

In the rapidly evolving landscape of 2024, technology trends are reshaping industries and redefining business strategies. From the C-suite perspective, executives are navigating a dynamic environment where artificial intelligence, augmented reality, and blockchain are not just buzzwords but integral components of transformative business models. The Chief Experience Officers (CXOs) are at the forefront, leveraging cutting-edge technologies to enhance customer experiences, streamline operations, and drive innovation. This blog delves into the strategic insights and perspectives of CXOs as they navigate the ever-changing tech terrain, exploring how these leaders are shaping the future of their organizations in the era of 2024’s technological evolution.

Share:
Technology Trends 2024

The Winds of Technology Blowing into 2024

As 2023 draws to a close, the digital landscape is poised for a seismic shift in 2024. Generative Artificial Intelligence (Gen AI) continues its integrative streak, disrupting industries from B2B to healthcare. Networking trends emphasize simplicity, while the synergy of cloud and edge computing with Gen AI promises real-time workflows. Quantum computing, cybersecurity, intelligent automation, and sustainable technology are key players, reshaping the technological fabric. Join us as we navigate the transformative currents of 2024, unraveling the impact on enterprises in our forthcoming article. Stay tuned for the tech evolution ahead!

Share: