Site icon Tutexchange

Learn How Connection and Channels works in RabbitMQ

Advertisements

In RabbitMQ, connections are essential as they enable communication between your application and the RabbitMQ server. Here’s an overview of connections in RabbitMQ:

TCP Connection between App and RabbitMQ Server

What is a Connection?

A connection is a TCP connection between your application and the RabbitMQ broker. Each connection can have multiple channels, which are virtual connections within a TCP connection. Channels are lightweight and can be used to perform different tasks concurrently.

TCP and Channels

Key Concepts:

  1. Connection: A TCP connection between your application and RabbitMQ.
  2. Channel: A virtual connection inside a TCP connection, allowing multiple independent interactions over a single connection.
  3. Virtual Host: A namespace for connections, exchanges, queues, and bindings.

In the Connection tab, you will see live connections for both message producers and consumers. It displays the usernames associated with each connection and their states. If SSL/TLS is being used, it will be indicated with a dark dot “.”. Additionally, the tab shows the protocol in use and provides network utilization statistics, including data from the client and to the client.

To view details of a connection, click on its name

View after Clicking on Connection Name

After clicking on the connection name, it will show all the details of the connection along with data rates, channels, client properties, runtime metric, and finally close connection.

If you want to close the connection then you can open the “close this connection” tab type the reason and click on the force close button.

Channel in RabbitMQ

What is a Channel?

In RabbitMQ, a channel is a virtual connection inside a physical connection (TCP connection). Channels are used to perform most of the operations such as defining queues, publishing messages, and consuming messages.

Why Use Channels?

In the Channel tab, you can view live channels for both message producers and consumers, along with their mode.

Modes:

Additionally, the tab displays the state of each channel.

Key Details:

Prefetch Count

Each channel can have two prefetch limits:

This column displays one or both limits if they are set.

To view details of a channel, click on its name (e.g., ‘[::1]:50753 (1)’). This will display all relevant information about the channel.

Conclusion

In this article, we explored how Connections and Channels work in RabbitMQ. We began by understanding how to view and manage connections, including details such as active connections and their statuses. We also examined the Unacked column, which represents messages received by a consumer but not yet acknowledged, as well as message rates that track published, confirmed, delivered, and acknowledged messages.

Exit mobile version