📎 Webclip
Message Queues & Message Brokers
Message queues are presented as a FIFO structure that lets producers and consumers communicate asynchronously. The page uses file processing in a web application to show how a job can be queued, stored in object storage, and later processed by a worker. It also lists background tasks, competing consumers, email and notification services, buffering, and payment retries as common uses.
Reading notes#
- A message queue stores messages in FIFO order, with new messages added at the back and removed from the front.
- Queues enable asynchronous communication between producer and consumer.
- A web app can create a job for an uploaded file, add it to a task queue, store the file in object storage, and let a worker process it later.
- Common uses include scheduling background tasks, distributing work across multiple workers, email and notification services, data buffering, and retrying failed payment transactions.
- A message broker is middleware that manages one or more message queues.
- Brokers can route messages to different destinations using routing keys.
- Brokers can transform messages by changing their format or content.
- Brokers can translate messages from one protocol to another, such as HTTP to JMS.
- Brokers support publish-subscribe communication.
- In the example, an Order Service publishes an OrderCreated message, while Inventory, Shipping, and Notification services subscribe to react to it.
