Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

RabbitMQ Non-Round Robin Dispatching

I'm interested in implementing the "Work Queues" model in RabbitMQ. However, I find that the broker does a simple round-robin based dispatching of tasks to workers.

https://www.rabbitmq.com/tutorials/tutorial-two-java.html

If a particular worker is busy doing a very heavy task and there are other free workers, the broker should be able to dispatch messages in queue to the next available worker and not the next worker in round-robin sequence. Is there a way to accomplish this using RabbitMQ?

like image 248
alpha_cod Avatar asked Mar 26 '14 22:03

alpha_cod


1 Answers

Maybe you are looking for Fair dispatch (https://www.rabbitmq.com/tutorials/tutorial-two-java.html) based on QoS.

channel.basicQos(1);

Using a QoS(1) one consumer is busy until doesn’t send the ACK,in this case another message is send to the next free consumer.

So if a consumer has a long process to do, it doesn’t receive messages.

If there are not a free consumers the messages remain to the queue.

like image 200
Gabriele Santomaggio Avatar answered Sep 21 '22 06:09

Gabriele Santomaggio