Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ: In pub/sub is the consumer polling the queue for new messages or does the server push messages?

I can't seems to find this information anywhere or maybe I am not understanding it. In the publish/subscribe pattern in RabbitMQ, when a producer produces a message how does the consumer(s) know there is a new message in the queue?

Do the consumers constantly poll the queue to check whether there are any new messages or does the exchange 'push' notification to consumers saying there is a new message?

like image 335
Kaladin Avatar asked Apr 17 '15 11:04

Kaladin


1 Answers

Consumer opens a network TCP connection and a channel to the RabbitMQ server.

A basic get will ask the server for a message: the message is pulled by the client from the server. If no message is available an empty response is sent to the client.

A consume will initiate a consumer scenario: server will push messages to the client.

So the consumer will know there is message because it can pull them (get) or they can be pushed to him (consume).

The exchange 'push' notification to consumers saying there is a new message?

The exchange are used for routing to queues. They pushes nothing as the consumers consume from queues.

like image 53
Nicolas Labrot Avatar answered Oct 13 '22 19:10

Nicolas Labrot