link: Message brokers
Message Queues
Diagram
Overview
A Message Queue is a form of Asynchronous service-to-service communication. Messages are stored in the queue until they are processed and deleted. Each message is processed only once, by a single consumer. This decouples the producer from the consumer, allowing for reliable and scalable communication between different components of an application.
Key Concepts
Producers and Consumers
- Producers: Applications or services that send messages to the queue.
- Consumers: Applications or services that receive and process messages from the queue.
Queue
- Queue: A data structure that holds messages until they are processed by consumers. Messages are processed in the order they are received (FIFO - First In, First Out).
Message Acknowledgment
- Acknowledge: Once a consumer processes a message, it sends an acknowledgment back to the queue. If a message is not acknowledged, it can be reprocessed.
How It Works
- Message Sending: A producer sends a message to the queue.
- Message Storage: The queue stores the message until a consumer is ready to process it.
- Message Retrieval: A consumer retrieves the message from the queue.
- Message Processing: The consumer processes the message.
- Message Acknowledgment: The consumer sends an acknowledgment to the queue indicating that the message has been processed.
- Message Deletion: The queue deletes the message once it has been acknowledged.