简体   繁体   English

RabbitMQ中的消费者数量(包括交易所)

[英]Count of consumers in RabbitMQ (with exchange)

If I don't use exchange in RabbitMQ, I can get count of consumers: 如果我在RabbitMQ中不使用交换功能,则可以获得以下用户数:

channel.QueueDeclare(queue: "Sellers",
                     durable: false,
                     exclusive: false,
                     autoDelete: false,
                     arguments: null);

int sellersCount = channel.ConsumerCount("Sellers");

How can I detect count of consumers with exchange: 如何通过交易所检测消费者人数:

channel.ExchangeDeclare(exchange: "Shop",
                        type: "direct");

channel.BasicPublish(exchange: "Shop",
                     routingKey: "Sellers",
                     basicProperties: null,
                     body: body1);

channel.BasicPublish(exchange: "Shop",
                     routingKey: "Clients",
                     basicProperties: null,
                     body: body2);

int sellersCount = ???
int clientsCount = ???

To elaborate on Evk 's comment , here's the RabbitMQ Management HTTP API documentation . 为了详细阐述Evk评论 ,这里是RabbitMQ管理HTTP API文档 Try GET /api/exchanges/vhost/name/bindings/source : 尝试GET /api/exchanges/vhost/name/bindings/source

A list of all bindings in which a given exchange is the source. 以给定交换为源的所有绑定的列表。

Note there are a couple previous answers to touch on this solution as well. 请注意,关于此解决方案,还有几个 先前的答案可以解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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