If I don't use exchange in RabbitMQ, I can get count of consumers:
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 . Try 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.
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.