Introduction to RabbitMQ

Learn what RabbitMQ does, when to use it, and how it differs from BullMQ.

🎯 Introduction

Learn what RabbitMQ does, when to use it, and how it differs from BullMQ.


🧱 What is RabbitMQ?

Programs need to exchange data. After a payment succeeds, for example, the order system needs to update its status and the notification system needs to send an alert. If the sender waits for each operation to finish, subsequent processing becomes tied to those operations.

RabbitMQ is a message broker: a service dedicated to receiving, temporarily storing, and forwarding data between programs. The sender submits a message, and the receiver retrieves it and performs its own work. A “message” is simply the data being passed, whether plain text or JSON containing a payment ID.

RabbitMQ runs independently. Business applications connect through client libraries, allowing programs written in Node.js, Java, and other languages to participate. RabbitMQ delivers messages; the applications still update orders and send notifications.


✨ What does it provide?

Asynchronous processing lets the sender continue working after submitting a message, without waiting for the receiver to finish. This suits operations that can happen later. Requests that require an immediate result generally still call an API directly.

Fewer direct dependencies between systems means the sender does not need to call every receiver individually. RabbitMQ routing configuration lets you add receivers without changing the sending logic. This separation is called decoupling.

Message buffering lets messages wait in a queue when receivers cannot keep up. A queue stores messages awaiting processing; disk and memory resources limit its capacity, so a backlog cannot grow indefinitely.


💡 Where it fits in a payment system

courseComponents.mermaid.loading

All three systems in the diagram need a copy of the message. Later, we will create three queues and run three independent receivers. If one system stops, its messages can remain in its own queue while the others continue processing.

With messaging, “payment succeeded” and “other systems finished processing” may happen at different times. The page should read the actual order status rather than report all subsequent operations as successful merely because a message was sent.


⚖️ How it differs from BullMQ

RabbitMQ commonly handles communication between services in backend architectures with multiple services. Such architectures split business responsibilities into independently running services. After confirming a payment, for example, the payment service notifies the order, notification, and accounting services through RabbitMQ, and each handles its work independently.

BullMQ commonly handles background jobs within a service. A notification service might enqueue email jobs for a background process, managing delays, retries, and job status.

Start with the requirement: consider RabbitMQ for business messages between services, and BullMQ for background jobs within a service. These are common roles rather than capability limits: BullMQ also supports cooperation between services, and RabbitMQ can handle background work within a single service.


❓ Questions and answers

Q1: Is RabbitMQ a frontend plugin?

No. It runs as a separate service. A Vue page calls a business API, and the backend connects to RabbitMQ. Never put connection credentials in frontend code.

Q2: Does using it prevent message loss?

Not automatically. We still need acknowledgements, persistence, and connection failure handling, covered later.

Q3: Can only applications with multiple systems use it?

No. A single application can use it to distribute background work. Whether to adopt it depends on messaging requirements and maintenance costs.


🧪 Exercise

Draw two flows: a payment system calling three APIs directly, and one distributing messages through RabbitMQ. Identify which approach can keep notification messages in an independent queue while the notification system is stopped.


🎉 You now know what RabbitMQ helps solve and are ready to set up the environment!