[英]How do you get RabbitMQ queue size from c# client?
我需要设置一个队列中可以有多少条消息的上限。 所以显然我需要知道队列中有多少个项目。 如何在不点击管理API或不使用QueueDeclarePassive的情况下从c#客户端检查RabbitMQ队列中的消息数?
下面是IModel对象上的消息计数功能的示例。 您无需使用QueueDeclarePassive或向管理插件提出休息请求。 应该有一个功能。
public uint GetMessageCount(string queueName)
{
using (IConnection connection = factory.CreateConnection())
using (IModel channel = connection.CreateModel())
{
return channel.MessageCount(queueName);
}
}
有关文档: http : //www.rabbitmq.com/releases/rabbitmq-dotnet-client/v3.6.4/rabbitmq-dotnet-client-3.6.4-client-htmldoc/html/type-RabbitMQ.Client.IModel.html #method-M:RabbitMQ.Client.IModel.MessageCount(System.String)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.