I am using RabbitMQ successfully. However, I have a problem where if I get in the situation where there are lots of messages on the queue then the consumer (a Windows service) tries to get them all and then just holds on to them but never actions or acknowledges them.
When the number of messages in the ready state is low then the consumers deal with the throughput fine, it is just if there has been an issue and there is a backlog then it gets far too greedy.
Is there a way to configure the maximum number of messages that a consumer will try and take responsibility for at any one time?
I can see the RequestedChannelMax
field on RabbitMQ.Client.ConnectionFactory
is that the correct setting to limit this?
Thanks
If you need to stop a consumer then just call basic cancel, that's the way to do it. Having durable queues is a matter that you solve when you declare the queue: durable=true auto_delete=false . Having persistent messages is determined when you publish them: delivery_mode=2.
Applications can subscribe to have RabbitMQ push enqueued messages (deliveries) to them. This is done by registering a consumer (subscription) on a queue. After a subscription is in place, RabbitMQ will begin delivering messages. For each delivery a user-provided handler will be invoked.
The definition of consumer utilisation is the proportion of time that a queue's consumers could take new messages. Increasing the prefetch limit will result in increases in consumer utilisation.
A consumer, by default will read as many messages as the bandwidth can handle regardless of actual message processing time by the consumer.
You need to set prefetch values by modifying the Quality of Service (QoS) of the channel to restrict how many messages it will try to pick up at one time. Check out basic.qos here. It has 3 parameters, a size (in octets), a count (the number of whole messages it will pick up at one time) and a global flag.
This blog post is an interesting read if you are interested in optimising throughput and talks about prefetching about 2/3 of the way down the page.
Hope that helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With