What is Messaging Queue?

Sneha TarnekarSneha Tarnekar
3 min read

Just like humans rely on communication to understand and connect with each other, applications also need a way to communicate effectively. Now here must arise a question, how do applications communicate? That's where Messaging Queues come into play!

Messaging Queue act as a Communication medium between different applications or services. As the name Messaging Queue(Message + Queue) itself describes is a queue of messages where the messages are transferred between sender to receiver.

In an online pizza ordering system, customer orders are converted into messages and added to a messaging queue. The first ordered pizza is the first to be processed by the pizza preparation station. In the same way, the message queue works.

Messaging Queue is a powerful communication mechanism used in computer systems to enable the exchange of messages between different services or systems where the sender and receiver don't need to be simultaneously available or connected for communication to occur. This provides asynchronous communication.

Messaging traditionally has 2 models

  1. Point-to-point (Queuing)

  2. Pub-Sub (Publish-Subscribe)

In a Point-to-point message sender and receiver have a one-to-one relationship. This type of messaging is used when we want to ensure that the message is sent and consumed only once. For example, This is preferred use for Financial transactions.

Publish-Subscribe messaging is a one-to-many relationship between sender and receiver. Imagine a person sending a message on a Slack channel to let's connect at 4 pm. Everyone added to the group will get notified. So they’d be able to plan their schedule accordingly.

Use cases of Messaging Queue

  1. Microservices Communication

    • Microservices can publish messages containing requests, events, or updates to a messaging queue, and other microservices can consume those messages to perform their respective tasks or react to the events.
  2. Task Management

    • Applications can enqueue tasks into a messaging queue, and worker processes or consumers can pick up those tasks and process them independently. This enables efficient handling of resources or time-consuming tasks without impacting the performance of the main application.
  3. Notifications and Real-Time Updates

    • When a user subscribes to specific events or updates, such as social media notifications, real-time messaging apps, or stock price alerts, the messages are published to a messaging queue, and the subscribed users receive them instantly.
  4. Asynchronous Processing

    • The sender can send a message to the queue without waiting for an immediate response from the receiver. The sender can continue with its own tasks, and the message will be stored in the queue until the receiver retrieves it.

Messaging queues play a vital role in modern application development with a wide range of use cases and the availability of implementation technologies. We can implement message queues using various technologies and protocols, such as Apache Kafka, RabbitMQ, AWS Simple Queue Service (SQS), etc.

31
Subscribe to my newsletter

Read articles from Sneha Tarnekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Sneha Tarnekar
Sneha Tarnekar

A Full Stack Developer and Senior Software Engineer skilled in Java, Spring Boot, Angular, Databases, Git, SDLC, and Agile methodology.