我试图在rabbitmq中监控我的队列状态,并尝试开发一个小脚本来监控他们的状态。我能够从Rabbitmq提供的HTTP API中检测运行和空闲状态。我想现在将队列推入流状态,以查看我得到的HTTP响应并检查它。我怎么做?我尝试通过队列推送大量数据,但是rabbitmq仍然可以很好地处理它。我正在粘贴下面的脚本:
send.py
import pika
message = ' '.join(str(i) for i in range(1000000))
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost'))
channel = connection.channel()
channel.queue_declare(queue='test3')
channel.basic_publish(exchange='', routing_key='test3', body=message)
print "[x] sent Hello World"
connection.close()
receive.py
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='test3')
print '[*] Waiting for messages...'
def callback(ch, method, properties, body):
print "[x] received %r" % (body,)
channel.basic_consume(callback, queue='test3', no_ack=True)
channel.start_consuming()