Reputation: 20133
I have two questions about RabbitMQ Work Queues:
As I understand it from the RabbitMQ tutorials, it seems that if I have a basic queue consumer client (just a basic "Hello, World!" consumer) and then I add a second consumer client for the same queue, then RabbitMQ will automatically dispatch the messages between those two queues in a round robin manner. Is that true (without adding in any extra configuration)?
My consumer clients are configured to only ever receive one message at a time, using (GetResponse response = channel.basicGet("my_queue", false)
. Since I am only ever receiving one message at a time, is it still necessary to set a prefetchCount (channel.basicQos(1)
) for fair dispatch?
Upvotes: 0
Views: 1594
Reputation: 16167
Answers to your questions:
However, your two questions 1 and 2 are not compatible. If you are using a consumer, it is designed to have messages pushed to it, and you don't use Basic.Get
. When you use a consumer, you will need to use Basic.QoS
to specify that the consumer can only "own" one unacknowledged message at a time. RabbitMQ will not push additional messages beyond the QoS limit.
Your alternative is to "pull" from the queue using Basic.Get
, and you will control your own destiny as far as how many messages you run at a time.
Does this make sense?
Upvotes: 2