i have one Job Distributor who publishes messages on different Channels.
Further, i want to have two (and more in the future) Consumers who work on different tasks and run on different machines. (Currently i have only one and need to scale it)
Let's name these tasks (just examples):
FIBONACCI(generates fibonacci numbers)RANDOMBOOKS(generates random sentences to write a book)
Those tasks run up to 2-3 hours and should be divided equally to each Consumer.
Every Consumer can have x parallel threads for working on these tasks.
So i say: (those numbers are just examples and will be replaced by variables)
- Machine 1 can consume 3 parallel jobs for
FIBONACCIand 5 parallel jobs forRANDOMBOOKS - Machine 2 can consume 7 parallel jobs for
FIBONACCIand 3 parallel jobs forRANDOMBOOKS
How can i achieve this?
Do i have to start x Threads for each Channel to listen on on each Consumer ?
When do i have to ack that?
My current approach for only one Consumer is: Start x Threads for each Task - each Thread is a Defaultconsumer implementing Runnable. In the handleDelivery method, i call basicAck(deliveryTag,false) and then do the work.
Further: I want to send some tasks to a special consumer. How can i achieve that in combination with the fair distribution as mentioned above?
This is my Code for publishing
String QUEUE_NAME = "FIBONACCI";
Channel channel = this.clientManager.getRabbitMQConnection().createChannel();
channel.queueDeclare(QUEUE_NAME, true, false, false, n