Check RabbitMQ queue size from client

后端 未结 9 1106
终归单人心
终归单人心 2021-01-30 20:12

Does anyone know if there\'s a way to check the number of messages in a RabbitMQ queue from a client application?

I\'m using the .NET client library.

9条回答
  •  孤城傲影
    2021-01-30 20:49

    my little snippet based on Myydrralls' answer. I think if he had code in his answer I might have noticed it much quicker.

    public uint GetMessageCount(string queueName)
    {
        using (IConnection connection = factory.CreateConnection())
        using (IModel channel = connection.CreateModel())
        {
            return channel.MessageCount(queueName);
        }
    }
    

提交回复
热议问题