以下代码是我用来计算消费者数量的代码:
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='IP ADDRESS'))
channel = connection.channel()
this=channel.queue_declare(queue="Queue_name",passive=True)
print this.method.consumer_count
Run Code Online (Sandbox Code Playgroud)
现在我获得的数量是活跃消费者的数量。但是,当消费者从队列中消费时,此计数将打印为零。现在我需要从队列中消费的消费者总数。这出现了 RabbitMQ 管理(作为消费者:0 活动 25 总计)
有没有办法在队列中有消息时获取从队列中消费的消费者总数的计数?
先感谢您