[rabbitmq-discuss] RabbitMQ .NET client BasicConsume and HandleBasicDeliver question

Emile Joubert emile at rabbitmq.com
Wed Jun 15 10:33:00 BST 2011


Hi,

On 15/06/11 10:08, T-zex wrote:
> Hi,
> 
> We are overriding DefaultBasicConsumer.HandleBasicDeliver method and
> use IModel.BasicConsume to subscribe to incoming messages:
> model.BasicConsume(queue, false, instanceOfDerivedConsumer);
> 
> When application fails to ack a message that message is requeued. How
> can I guarantee that BasicConsume is receiving one message at a time?
> How to deterministically stop consuming when application detects that
> it is unable to process a message and prevent the second message from
> arriving? How to make sure that there is one and only one unacked
> message and that message is at the peak of broker queue.

The solution is to set the prefetch count of the channel to 1 using
IModel.BasicQos(). Also see
http://www.rabbitmq.com/amqp-0-9-1-quickref.html#basic.qos .
Note that rabbit does not implement the prefetch size or global
parameters to the same method.


-Emile


More information about the rabbitmq-discuss mailing list