简体   繁体   中英

RabbitMQ - multiple consumers single publisher

When using RabbitMQ to handle heavy messages, i need to add more than one consumer for the same publisher and task. Most of the tutorials from RabbitMQ and across the web suggest to register multiple consumers for that task (Although most of them opens a new process for each consumer in a new shell, and mine would all go under the same application). Given that every consumer needs it's own channel (correct me if i'm wrong here), that means that for X consumers we would have X channels open.
The alternative that comes to mind is having one consumer that ships the messages to a Thread pool containing tasks that implement the heavy work from the messages, which is a little more clumsy but requires only one open channel.
Is there a preferable way to implement this out of these two options? Is there a third option?

Yes, every consumer needs its own channel. Your best option is to run each consumer in its own thread, with its own connection and channel. RabbitMQ will round-robin delivery of messages to consumers. Be sure to read about prefetch (QoS).


the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow. RabbitMQ团队监视rabbitmq-users邮件列表 ,仅在某些情况下回答关于StackOverflow的问题。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM