Producers, Consumers, and the AMQP Model
Connect to a broker and move messages through exchanges, queues, and bindings using the AMQP protocol.
Why Message Queues?
In a Node.js backend, calling another service directly couples the two together: if the receiver is slow or down, the caller blocks or fails. A message queue decouples them. The sender drops a message into a broker and moves on; the receiver picks it up whenever it is ready.
- Asynchronous — the producer never waits for the consumer.
- Resilient — messages survive while a consumer is offline.
- Scalable — add more consumers to drain a backlog faster.
RabbitMQ is a popular broker that speaks AMQP 0-9-1, the protocol we use throughout this lesson.
The AMQP Model
AMQP separates the act of publishing from the act of storing. A producer never writes to a queue directly. Instead it publishes to an exchange, and the exchange routes the message to one or more queues based on bindings.
- Producer — publishes messages.
- Exchange — receives messages and decides where they go.
- Binding — a rule linking an exchange to a queue (often with a routing key).
- Queue — buffers messages until a consumer reads them.
- Consumer — subscribes to a queue and processes messages.
This indirection is what makes routing flexible: change bindings, not producer code.
All lessons in this course
- Producers, Consumers, and the AMQP Model
- Exchange Types: Direct, Topic, Fanout, and Headers
- Acknowledgements, Dead-Letter Queues, and Retries
- Work Queues, Prefetch, and Competing Consumers