[rabbitmq-discuss] Non-blocking Consumers approach
Matthias Radestock
matthias at rabbitmq.com
Mon Aug 27 14:24:07 BST 2012
Mahesh,
On 27/08/12 13:37, Mahesh Viraktamath wrote:
> I read the API guide and still stuck to the QueuingConsumer, for each
> incoming message I create a new service thread (with common channel,
> without that the service won't know which message to acknowledge). But
> in the guide, it is mentioned that the channel should be created for
> each thread. Now, my question is does this guide assumes that we run
> different consumer threads? *I can't understand the concept of different
> consumer threads*. I run a single consumer and use basicConsume() to
> listen to the messages and each message (nextDelivery()) will give rise
> to a new service thread. Again, each message creating a thread is scary !
>
> If it helps, I am running the consumer as a java application and use
> basicConsume() and nextDelivery() in a while loop to process the
> messages. Our application sends messages to these non-stop. So, I am
> looking for a consumer which will not block the incoming messages when
> it is processing a large message.
I suggest you create N channels and for each channel:
- set the basic.qos prefetch to 1 or some other low-ish value (for fair
dispatch)
- create a consumer as shown in
http://www.rabbitmq.com/api-guide.html#consuming
You write above that you only have one channel because "without that the
service won't know which message to acknowledge", but the channel is
accessible via the context (as shown in the example), so there is no
ambiguity.
Obviously message ordering goes out of the window, but that's the case
for any scheme where messages are handled by multiple threads.
Regards,
Matthias.
More information about the rabbitmq-discuss
mailing list