2017-02-01 12:51:32
0
I am trying to fetch the total number of consumers for a particular queue in RabbitMQ. I wrote my code in C# using RabbitMQ client for .Net.
string user = ConfigurationManager.AppSettings[“rmq_user”];
string pword = ConfigurationManager.AppSettings[“rmq_pass”];
string port = ConfigurationManager.AppSettings[“rmq_port”];
string host = new Uri(ConfigurationManager.AppSettings[“rest_api_url”]).Host;
var factory = new ConnectionFactory();
factory.Uri = “amqp://” + user + “:” + pword + “@” + host + “:” + port;
using (var connection = factory.CreateConnection())
{
using (var channel = connection.CreateModel())
{
var consumerCount = ((RabbitMQ.Client.Impl.ModelBase)(channel)).m_consumers;
}
}
I am getting var consumerCount = ((RabbitMQ.Client.Impl.ModelBase)(channel)).m_consumers; as 0. However I can see the consumers in the RabbitMQ web and I have made sure that the consumers do exist in that queue.
Is this the correct way to get the consumer count or I am doing something wrong I know this can be done using RabbitMQ admin but I need to do it in C#.
Please let me know if I can give some more details.
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,会注明原创字样,如未注明都非原创,如有侵权请联系删除!;3.作者投稿可能会经我们编辑修改或补充;4.本站不提供任何储存功能只提供收集或者投稿人的网盘链接。 |
标签: #rabbitmq消费者数量 #20170201 #1251320I #am #trying #To #fetch #The