liveBook · Manning

Message queue

As explained in Grokking Software Architecture

An intermediary buffer that holds messages for consumers to retrieve and process.

A message queue holds work for consumers to retrieve and process later. By moving noncritical or slow work out of a synchronous request, it lets the user-facing task finish without waiting for every service. section 6.8.4 section 7.3.4

Choose a queue when a job should be done once, not broadcast to every service:

  • A producer adds a message; one consumer from a worker pool takes it. This distributes work such as image resizing or order processing. section 7.4.1
  • Use a topic instead when multiple services each need a copy of an event. section 7.4.1

Print the label later

An order can be checked and paid for synchronously while its shipping-label task waits in a queue. If the shipping service is unavailable, the order need not fail just because label printing cannot happen immediately. section 6.8.4

Figure 7.9 Queues vs. Topics. In a Queue model, Competing Consumers load-balance tasks across multiple workers, ensuring that each message is claimed and processed by only one worker (1-to-1). In contrast, a Topic acts as a prism using a Fan-Out (Pub/Sub) approach to broadcast and duplicate a single event (1-to-Many). This allows multiple distinct services (such as Shipping, Email, and Analytics) to receive their own copies of the event and react to it independently.

Compare one-to-one queue processing with one-to-many topic broadcasting. section 7.4.1

How Grokking Software Architecture covers it

How deep it goes
Explains point-to-point delivery, competing consumers, and use cases alongside the contrast with topic broadcast.
Examples
Uses shipping-label printing, image resizing, order processing, and background AI analysis as queued work.
What you can do after
Apply queues to defer noncritical or long-running work and distribute each task to one worker.
How it connects
Connects queues to event-driven architecture, asynchronous communication, consumers, and topics.

Also explained in

Compare how 3 books explain message queue →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Grokking Software Architecture. The section links point to the parts of the book it draws on.