How RabbitMQ works - AMQP, not HTTP
This is an important question, because RabbitMQ (and message brokers more broadly) work on a fundamentally different model than HTTP, even though both "send data over the network". The short answer: no, messages are NOT sent as an HTTP request - RabbitMQ uses its own binary protocol (AMQP) over an ordinary, long-lived TCP connection.
AMQP vs HTTP - a different communication model
HTTP is a request-response model: the client opens a connection (or uses an existing one), sends a request, waits for a response, and the connection ends (or is reused, but always in the "request → response" pattern).
AMQP (Advanced Message Queuing Protocol) is a binary protocol designed specifically for passing messages - RabbitMQ speaks AMQP 0-9-1 by default (newer versions also support AMQP 1.0). The key difference: it is not "a request for something" - it is sending a message to a structure (a queue) which exists independently of whether anyone is listening at the moment.
How it physically works - one connection, many channels
Aplikacja .NET (np. RebusDemo.Server)
|
| 1x TCP connection (port 5672), OPEN PERMANENTLY
|
RabbitMQ Broker
When the application calls UseRabbitMq("amqp://guest:guest@localhost:5672", ...), the RabbitMQ.Client library (on which Rebus.RabbitMq is based) opens one, long-lived TCP connection to the broker on port 5672 - and that connection stays open for the whole lifetime of the application, it is not closed after each message.
Inside that single TCP connection channels are created - lightweight, virtual "sub-connections" multiplexed over one network socket, so you don't have to open a new TCP connection for every operation (sending, receiving, declaring a queue, etc.) - this is much more efficient than HTTP without keep-alive, where every request is potentially a new connection.
The communication model - Producer → Exchange → Queue → Consumer
KLIENT (Producer) RabbitMQ SERWER (Consumer)
| | |
| bus.Send(command) | |
|------------------------------->| Exchange -> routing -> Queue |
| (AMQP "basic.publish") | (the message WAITS in the queue, |
| | even if the Server is offline) |
| | |
| |------- PUSH, gdy Consumer gotowy ->|
| | (AMQP "basic.deliver") |
The key elements of the AMQP model: - Exchange - the entry point for published messages; it decides (based on the routing key / exchange type) which queue (or queues) the message goes to - Queue - a buffer in which the message waits, even if no consumer is connected at the moment - Binding - a rule linking an exchange with a queue
This is exactly what happens "under the hood" with bus.Send() and bus.Publish() in Rebus - bus.Send() is a publish with routing to one specific queue (e.g. orders-queue), while bus.Subscribe<T>() with bus.Publish() is a mechanism in which Rebus creates a topic exchange and adds the subscriber's queue (e.g. notifier-queue) as a binding to that exchange.
The key practical difference - PUSH, not PULL
This is probably the most important conceptual difference compared with HTTP:
- HTTP - the client asks ("is there anything new?") - this is the pull model
- AMQP (in typical use) - the broker pushes the message to the consumer as soon as it is available and the consumer is ready (
basic.consumeregisters a "callback" on the client side, the broker invokes it when a message arrives) - this is the push model
That is why in handlers of the IHandleMessages<T> type (Rebus) or IHandleMessages<T> there is no polling loop asking "is there a new message?" - Handle() is invoked automatically, because RabbitMQ itself sends the message to the client the moment it is available. This is, incidentally, exactly the mechanism thanks to which the server "listens" without busy-looping and without using CPU on waiting.
And what about port 15672 - isn't that HTTP?
There is an important distinction here that is easy to mix up: port 15672 (the admin panel) is a completely different, additional interface - it is a real HTTP/REST API (the rabbitmq_management plugin), used solely for management and inspection (how many messages are in a queue, statistics, creating queues manually from the UI). No business message ever passes through this port - it is a separate, "side" administrative channel, completely independent of port 5672, over which the AMQP traffic actually flows.
Summary - a table
| HTTP | AMQP (RabbitMQ, port 5672) | |
|---|---|---|
| Model | Request-response, pull | Broker push to a ready consumer |
| Connection | Usually short-lived / per-request | One long-lived TCP + multiplexed channels |
| Who initiates delivery | The client (by asking) | The broker (by pushing when the message is ready) |
| Data durability | No - the response is lost if the client didn't receive it | Yes - the message WAITS in the queue, even when the consumer is offline |
| Typical port | 80/443 (HTTP/HTTPS), here: 15672 (admin panel only) | 5672 (the actual message traffic) |
Summary - a concise answer in an interview
RabbitMQ communicates through the AMQP protocol, a binary protocol designed for passing messages, not through HTTP. The client opens one long-lived TCP connection to the broker (port 5672 by default), inside which lightweight channels for individual operations are multiplexed. Messages flow through Exchange → Queue → Consumer, and the delivery model is push, not pull - the broker itself pushes the message to a ready consumer as soon as it is available, with no need for polling. Port 15672, if it is visible, is a separate HTTP admin panel - it has nothing to do with the actual transport of business messages.