[rabbitmq-discuss] Pika, Detect publish failure when broker becomes unavailable
smetj.net at gmail.com
Fri Mar 2 00:08:58 GMT 2012
I'm using pika 0.9.5 and trying to figure out how to detect whether
RabbitMQ is still available/unavailable after creating a connection to it.
When I stop Rabbit between the channel creation and publishing the message,
there appears to be no way of detecting whether rabbit is still
Publishing the message doesn't generate any error, connection.is_open
always returns True...
Anyone an idea how to deal with this?
from pika.adapters import SelectConnection
from pika.adapters import BlockingConnection
parameters = pika.ConnectionParameters(host='sandbox')
connection = BlockingConnection(parameters)
channel = connection.channel()
channel.queue_declare(queue="test", durable=True, exclusive=False,
#I stop rabbitmq here
print connection.is_open #Returns True so this doesn't work
#this doesn't generate any error
channel.basic_publish(exchange='', routing_key="test", body="Hello World!",
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss