0% found this document useful (0 votes)
3 views4 pages

Message Queue

Message queues are components of messaging middleware that facilitate asynchronous communication between independent applications by storing messages until they can be processed. They consist of message producers, queues, consumers, and optionally brokers, allowing for reliable message delivery and preventing data loss. There are two main types of message queues: point-to-point, which ensures messages are consumed by one consumer, and publish-subscribe, which routes messages to multiple subscribed consumers.

Uploaded by

ppkarhade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Message Queue

Message queues are components of messaging middleware that facilitate asynchronous communication between independent applications by storing messages until they can be processed. They consist of message producers, queues, consumers, and optionally brokers, allowing for reliable message delivery and preventing data loss. There are two main types of message queues: point-to-point, which ensures messages are consumed by one consumer, and publish-subscribe, which routes messages to multiple subscribed consumers.

Uploaded by

ppkarhade
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Module 2-Communication

Message Queue
 A message queue is a component of messaging middleware solutions that enables independent
applications and services to exchange information.
 Message queues store “messages”—packets of data that applications create for other applications to
consume—in the order they are transmitted until the consuming application can process them.
 This enables messages to wait safely until the receiving application is ready, so if there is a problem
with the network or receiving application, the messages in the message queue are not lost.
 This model, known as asynchronous messaging, prevents data loss and enables systems to continue
to function if processes or connections fail. This allows developers to keep processes and
applications separate, keeping their communications self-contained and event-driven to make the
architecture more reliable.

Components of a Message Queues System


 Message Producer: Messages are created and sent to the message queue by the message producer. Any
program or part of a system that produces data for sharing can be considered this.
 Message Queue: Until the message consumers consume them, the messages are stored and managed by
a data structure or service called the message queue. It serves as a mediator or buffer between
consumers and producers.
 Message Consumer: Messages in the message queue must be retrieved and processed by the message
consumer. Messages from the queue can be read concurrently by several users.
 Message Broker (Optional): In some message queue systems, a message broker acts as an intermediary
between producers and consumers, providing additional functionality like message routing, filtering,
and message transformation.

How Message Queues Work?


Below are some steps to understand how message queues work:
 Step 1: Sending Messages: The message producer creates a message and sends it to the message queue.
The message typically contains data or instructions that need to be processed or communicated.
 Step 2: Queuing Messages: The message queue stores the message temporarily, making available for
one or more consumers. Messages are typically stored in a first-in, first out (FIFO) order.
 Step 3: Consuming Messages: Message consumers retrieve messages from the queue when they are
ready to process them. They can do this at their own pace, which enables asynchronous communication.
 Step 4: Acknowledgment (Optional): In some message queue systems, consumers can send
acknowledgments back to the queue, indicating that they have successfully processed a message. This is
essential for ensuring message delivery and preventing message loss.

Types of Message Queues


There are two main types of message queues in system design:
1. Point-to-Point Message Queues
Point-to-point message queues are the simplest type of message queue. When a producer sends a
message to a point-to-point queue, the message is stored in the queue until a consumer retrieves it. Once
the message is retrieved by a consumer, it is removed from the queue and cannot be processed by any
other consumer.
Point-to-point message queues can be used to implement a variety of patterns such as:
 Request-Response: A producer sends a request message to a queue, and a consumer retrieves the
message and sends back a response messages.
 Work Queue: Producers send work items to a queue, and consumers retrieve the work items and process
them.
 Guaranteed Delivery: Producers send messages to a queue, and consumers can be configured retry
retrieving messages until they are successfully processed.

2. Publish-Subscribe Message Queues


 Publish-Subscribe Message Queues are more complex than point-to-point message queues. When
a producer publishes a message to publish/subscribe queue, the message is routed to all
consumers that are subscribed to the queue. Consumers can subscribe to multiple queues, and
they can also unsubscribe from queues at any time.
 Publish-Subscribe Message Queues are often used to implement real-time streaming applications,
such as social media and stock market tickers.
 They can also be used to implement event-driven architecture, where components of a system
communicate with each other by publishing and subscribing to events.

Advantages of Message Queue

1) Better Performance
2) Increased Reliability
3) Granular scalability
4) Simplified Decoupling
5) Break up Applications

You might also like