# Part 1: RabbitMQ for beginners - What is RabbitMQ?

By Lovisa Johansson. Last updated 10 November 2026.

The first part of our guide, **RabbitMQ for beginners,** explains what RabbitMQ and message queueing are - it will give a brief understanding of message queueing and defines important concepts. The guide goes on to explain the steps to set up a connection and the basics of publishing/consuming messages from a queue.

#### This blog series is a living document that is continually updated. Last updated November 2026.

RabbitMQ is message-queueing software also known as a _message broker_ or _queue manager._ In simple terms, RabbitMQ is software where queues are defined, to which applications connect in order to send messages to each other.

![message queue](/img/blog/message-queue-small.png "message queue")

A message can contain various types of information. It could, for example, include information about a process or task that should start on another application (which could even be on another server), or it could be just a simple text message.

The queue-manager software (message broker) stores messages until a receiving application connects to the queue and takes the messages off the queue for processing.

All articles from **Getting Started with RabbitMQ** can be downloaded as a free ebook [here](/rabbitmq-ebook/).

An **online training tool for RabbitMQ** created by CloudAMQP can be found at: [https://training.cloudamqp.com/](https://training.cloudamqp.com/)

### RabbitMQ Example

A message broker acts as a middleman for various services (e.g., a web application, as in this example). They can be used to reduce loads and delivery times of web application servers by delegating tasks that would normally take up a lot of time or resources to a third party that has no other job.

In this guide, we follow a scenario where a web application allows users to upload information to a website. The site will handle this information, generate a PDF, and email it back to the user. This process will, in this example, take several seconds and is one of the good reasons why a message queue will be used to perform the task.

When the user enters information into the web interface, the web application will create a “PDF processing” message that includes all of the important information needed to perform the task. That message is then placed onto a queue defined in RabbitMQ.

A producer publishes a message to the RabbitMQ broker, where it waits in a queue. A consumer receives the message and sends an ack, and then the message is removed from the queue.

The basic architecture of a message queue is simple. There are client applications called **producers** that create messages and deliver them to the broker. Other applications, called **consumers,** connect to a queue and subscribe to the messages for processing. Software can act as a producer, a consumer, or both a consumer and a producer of messages. Messages placed onto the queue are stored until the consumer retrieves them.

##### When and why should you use RabbitMQ?

Message queueing allows web servers to respond quickly to requests instead of being forced to perform resource-heavy procedures on the spot that may delay response time. Message queueing is also useful when you want to distribute messages to multiple consumers or to balance loads among workers.

The consumer takes a message off the queue and starts processing the PDF. At the same time, the producer continues to add new messages to the queue. The consumer can be on a totally different server than the producer, or they can be located on the same server. The request can be created in one programming language and handled in another programming language. The point is, these two applications will only communicate through the messages they are sending to each other, which means the sender and receiver have **low coupling.**

![RabbitMQ beginners tutorial](/img/blog/rabbitmq-beginners-updated.png "RabbitMQ beginners tutorial")

1. The user sends a PDF creation request to the web application.
2. The web application (the producer) sends a message to RabbitMQ that includes data from the request such as name and email.
3. An exchange accepts the messages from the producer and routes them to the correct message queues for PDF creation.
4. The PDF processing worker (the consumer) receives the task message and starts processing the PDF.

#### Exchanges

In RabbitMQ, messages are not published directly to a queue. Instead, the producer sends messages to an exchange. The exchange is responsible for routing messages to different queues using bindings and routing keys. A binding is a link between a queue and an exchange.

![RabbitMQ Exchanges, Bindings and Routing Keys](/img/blog/exchanges-bidings-routing-keys.svg "RabbitMQ Exchanges, Bindings and Routing Keys")

##### Message flow in RabbitMQ

1. The producer publishes a message to an exchange. When creating an exchange, the type must be specified. This topic will be covered later.
2. The exchange receives the message and is now responsible for routing it. The exchange takes different message attributes into account, such as the routing key, depending on the exchange type.
3. Bindings must be created from the exchange to queues. In this case, there are two bindings to two different queues. The exchange routes the message into the queues depending on message attributes.
4. The messages stay in the queue until they are handled by a consumer.
5. The consumer handles the message.

#### Types of exchanges

![RabbitMQ exchange types](/img/blog/exchanges-topic-fanout-direct.png "RabbitMQ exchange types")

These are the four main exchange types in RabbitMQ:

- **Direct:** The message is routed to the queues whose binding key exactly matches the routing key of the message. For example, if the queue is bound to the exchange with the binding key _pdfprocess, a message published to_ the exchange with a routing key _pdfprocess is routed to that queue._
- **Fanout:** A fanout exchange routes messages to all of the queues bound to it.
- **Topic:** The topic exchange does a wildcard match between the routing key and the routing pattern specified in the binding.
- **Headers:** Headers exchanges use the message header attributes for routing.

In part 2, the code examples use direct exchanges, including the default exchange. A deeper understanding of the different exchange types, binding keys, routing keys and how or when you should use them can be found in [Part 4: RabbitMQ for beginners - Exchanges, routing keys and bindings](/blog/part4-rabbitmq-for-beginners-exchanges-routing-keys-bindings/).

#### RabbitMQ and server concepts

Before digging deeper into RabbitMQ, let's go over the elements and concepts.

- **Producer:** Application that sends the messages to the broker.
- **Consumer:** Application that receives the messages from the broker.
- **Queue:** Buffer within the broker that stores messages.
- **Message:** Information that is sent from the producer to a consumer through the broker.
- **Connection:** A TCP connection between your application and the broker.
- **Channel:** A virtual connection inside a connection. When publishing or consuming messages from a queue - it's all done over a channel.
- **Exchange:** Receives messages from producers and routes them to queues depending on rules defined by the exchange type. To receive messages, a queue needs to be bound to at least one exchange.
- **Binding:** A binding is a link between a queue and an exchange.
- **Routing key:** A key that the exchange uses to decide how to route the message to queues. Think of the routing key like an _address for the message._
- **Acknowledgement (ack):** A signal from the consumer telling the broker that a message has been handled and can be removed from the queue. If a consumer disconnects before acknowledging a message, RabbitMQ puts the message back on the queue, so another consumer can pick it up.
- **AMQP:** Advanced Message Queuing Protocol. AMQP 0-9-1 is the protocol most RabbitMQ clients use, and the one used in this guide. RabbitMQ also supports AMQP 1.0, MQTT, and STOMP.
- **Users:** It is possible to connect to RabbitMQ with a given username and password. Every user can be assigned permissions such as rights to read, write and configure privileges within the instance. Users can also be assigned permissions for specific virtual hosts.
- **Vhost, virtual host:** Provides a way to segregate applications using the same RabbitMQ instance. Users can have different permissions in different vhosts, and queues and exchanges exist in only one vhost.

#### Queue types

RabbitMQ has three queue types. You choose the type when you declare the queue.

- **Quorum queues:** Replicated across several nodes, so messages survive if a node goes down. Quorum queues are the recommended choice when data safety matters, which is most production use cases.
- **Classic queues:** The original queue type, stored on a single node. A good fit for temporary queues or when losing a message now and then is acceptable.
- **Streams:** An append-only log where messages are not removed when consumed. Several consumers can read the same messages, and replay them from any point.

The examples in this guide use classic queues to keep things simple. Read more in [Lifting the lid on quorum queues](/blog/lifting-the-lid-on-quorum-queues/) and [When to use RabbitMQ streams](/blog/rabbitmq-streams-and-replay-features-part-1-when-to-use-rabbitmq-streams/).

**At the beginning of this article,** we had one producer (the website application) and one consumer (the PDF processing application). If the PDF processing application crashes, or if many PDF requests are coming at the same time, messages would continue to stack up in the queue until the consumer restarts. Once active again, it would then process all the messages, one by one, in order.

### Set up a RabbitMQ instance

To follow this guide you need to set up a CloudAMQP instance or download and install RabbitMQ. CloudAMQP offers a hosted RabbitMQ solution, meaning that all you need to do is sign up for an account and create an instance. You do not need to set up and install RabbitMQ or care about cluster handling, CloudAMQP will do that for you. CloudAMQP can be used for free with the plan Little Lemur.

[Get your free instance now!](https://customer.cloudamqp.com/signup?topic=get_started)

![RabbitMQ tutorial](/img/docs/create-new-instance-cloudamqp.png "RabbitMQ tutorial")

After your instance is created, click on your instance details to find your username, password, and connection URL for your cloud-hosted RabbitMQ instance.

![RabbitMQ tutorial](/img/docs/create-new-rabbitmq-server-cloudamqp.png "RabbitMQ tutorial")

### Getting started with RabbitMQ

Immediately after creating a RabbitMQ instance you can send messages using different languages, platforms, and operating systems. This way of handling messages decouples your processes and creates a highly scalable system.

**To get started, open the management interface to get an overview of your RabbitMQ server.**

#### The Management Interface - Management and Monitoring

RabbitMQ offers a web-based user interface (UI) for the management and monitoring of your RabbitMQ server. The RabbitMQ management interface is enabled by default in CloudAMQP and a link can be found on the details page for your CloudAMQP instance.

From the management interface, it is possible to handle, create, delete and list queues. It is also possible to monitor queue length, check message rate, or change and add users permissions and much more.

![Rabbitmq monitoring tutorial](/img/screens/new-rabbitmq-manager.jpg "Rabbitmq monitoring tutorial")

More information about the management interface can be found in [Part 3 - The management interface](/blog/part3-rabbitmq-for-beginners-the-management-interface/).

#### How to publish and subscribe messages with RabbitMQ

Most applications talk to RabbitMQ using [AMQP 0-9-1](https://www.cloudamqp.com/docs/amqp), the protocol used in this guide. To be able to communicate with RabbitMQ you need a library that understands the same protocol as RabbitMQ. Download the client library for the programming language that you intend to use for your applications.

A client library is an application programming interface (API) for use in writing client applications. A client library has several methods - in this case, to communicate with RabbitMQ. The methods should be used when you connect to the RabbitMQ broker (using the given parameters, hostname, port number, etc.) or when you declare a queue or an exchange. There is a choice of libraries for almost every programming language.

**Steps to follow when setting up a connection and publishing a message/consuming a message:**

1. **Set up/create a connection object.**  
   The username, password, connection URL, port, etc., will need to be specified. A TCP connection is set up between the application and RabbitMQ when the connection object is created or opened, depending on the client library.
2. **Create a channel within the TCP connection.**  
   This channel serves as a pathway for sending and receiving messages through the connection interface.
3. **Declare/create a queue.**  
   Declaring a queue will cause it to be created if it does not already exist. All queues need to be declared before they can be used.
4. **Set up exchanges and bind a queue to an exchange in subscriber/consumer.**  
   All exchanges must be declared before they can be used. An exchange accepts messages from a producer application and routes them to message queues. To route messages to queues, bind the queues to an exchange.
5. **In publisher:** Publish a message to an exchange.  
   **In subscriber/consumer:** Consume a message from a queue.
6. **Keep the connection open.**  
   Opening a connection is expensive, so reuse the same connection and channel for many messages instead of opening a new one per message. Close them when your application shuts down.

#### Sample code

Sample code will be given in part 2, starting with [Part 2.1 - Ruby,](/blog/part2-1-rabbitmq-for-beginners-example-and-sample-code-ruby/) followed by [Part 2.2 - Node.js,](/blog/part2-2-rabbitmq-for-beginners-example-and-sample-code-node-js/) and [Part 2.3 - Python](/blog/part2-3-rabbitmq-for-beginners-example-and-sample-code-python/). Having different programming languages on different parts of the system is possible - for example, the publisher could be written in Node.js and the subscriber in Python.

[Enjoy RabbitMQ? Take a look at LavinMQ, a fast and easy-to-use AMQP message broker with great performance. Try LavinMQ for free](https://customer.cloudamqp.com/signup?topic=try_lavinmq)

Please email us at [contact@cloudamqp.com](mailto:contact@cloudamqp.com) if you have any suggestions or feedback.

Guide — RabbitMQ for beginners

### CloudAMQP - industry-leading RabbitMQ as a Service

Fully managed RabbitMQ clusters on all major clouds. Free plan available - no credit card required.

[Sign up for free](https://customer.cloudamqp.com/signup?topic=get_started)

[Part 2: Sample code](/blog/part2-rabbitmq-for-beginners-example-and-sample-code/)
