【发布时间】:2013-06-17 22:34:56
【问题描述】:
您如何确保使用Pika 传递消息?默认情况下,如果消息未成功传递,它不会向您提供错误。
在此示例中,可以在 pika 确认连接已断开之前发送几条消息。
import pika
connection = pika.BlockingConnection(pika.ConnectionParameters(
host='localhost'))
channel = connection.channel()
channel.queue_declare(queue='hello')
for index in xrange(10):
channel.basic_publish(exchange='', routing_key='hello',
body='Hello World #%s!' % index)
print('Total Messages Sent: %s' % x)
connection.close()
【问题讨论】:
标签: python rabbitmq message pika