RabbitMQ中的消费者数量(与交换)

时间:2017-05-13 12:25:37

标签: c# .net rabbitmq amqp

如果我不在RabbitMQ中使用交换,我可以得到消费者的数量:

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

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

如何通过交换来检测消费者的数量:

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 = ???

1 个答案:

答案 0 :(得分:0)

详细说明Evk' commentRabbitMQ Management HTTP API documentation。试试GET /api/exchanges/vhost/name/bindings/source

  

给定交换所源的所有绑定的列表。

请注意,此解决方案也有couple previous个答案。