Is it possible to dispatch no more than N number of messages from the queue at a given time with distributed consumers?

StackOverflow https://stackoverflow.com/questions/17632998

I have a distributed system that reads messages from RabbitMQ. In my situation now I need to process no more than N msgs/s.

For example: Imagine service A that sends text messages (SMS). This service can only handle 100 msgs/s. My system has multiple consumers that reads data from RabbitMQ. Each message needs to be processed first and than be send to service A. Processing time is always different.

So the question:

  • Is it possible to configure queue to dispatch no more than 100 msgs/s to multiple consumers?
有帮助吗?

解决方案

You can use the prefetch_size parameter of the qos method to limit throughput to your consumers.

channel.basic_qos(100);

See also: http://www.rabbitmq.com/blog/2012/05/11/some-queuing-theory-throughput-latency-and-bandwidth/

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top