RabbitMQ how to throttle the consumer

后端 未结 1 1232
粉色の甜心
粉色の甜心 2020-12-13 19:46

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 servic

相关标签:
1条回答
  • 2020-12-13 20:41

    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!

    0 讨论(0)
提交回复
热议问题