Question

I have one producer, one queue and N consumers. Producer creates 'jobs' to be performed by consumers. I'd like to use pull model, in which consumer pulls job from queue, when it finishes the previous job, not push model with round robin, where jobs are divided by equal to consumers.

My consumers use the same code, but when I ran it, the first one connects and receives all jobs. Even when looking at it in debug, the first gets everything but the second etc do not get any message (even when it executes receive before first one executes receive which returns it some jobs).

Connection URL: "amqp://guest:guest@prodconstest/?brokerlist='tcp://127.0.0.1:5767'"

Code for every consumer does:

  1. creates AMQConnection
  2. creates queue session with auto ack
  3. connection start
  4. create queue "ADDR:" + queueName + "; {create: always, link:{x-subscribes: {exclusive: false}}}"
  5. create consumer

Is it theoretically possible to achive using AMQP queue? If so, how?

Was it helpful?

Solution

It seems that I have to change maxprefetch parameter in connection URL. Default value 5000 is too big for my use case, changing it to 1 makes this system work.

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