I need to set an upper limit on how many messages can be in a queue. So obviously I need to know how many items are in a queue. How do you check the number of messages in a Rabb
Below is a example of the message count function on the IModel object. You do not need to use QueueDeclarePassive or make rest request to the managment plugin. There is a function right there where it should be.
public uint GetMessageCount(string queueName)
{
using (IConnection connection = factory.CreateConnection())
using (IModel channel = connection.CreateModel())
{
return channel.MessageCount(queueName);
}
}
For documentation: 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)