Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top