[rabbitmq-discuss] Pika, Detect publish failure when broker becomes unavailable
wzasqn
chandij.piotr at gmail.com
Fri Mar 2 12:07:10 GMT 2012
Hi,
I have the same problem – I fought that if we set channel into confirm
mode:
channel.confirm_delivery(callback = confirm_handler)
should call function when we received acknowledge from RabbitMQ but
unfortunately not, that function is called when we closing channel
(BlockingChannel) – channel.close() – that function is freezing.
We can check is connection is open (connection.open) but this one not
guarantees that message was received.
So I will ask one more time ;-) Anyone have an idea how to deal with
that?
Thanks,
p
On Mar 2, 12:08 am, Jelle Smet <smetj.... at gmail.com> wrote:
> Hi all,
>
> 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
> alive/available.
> Publishing the message doesn't generate any error, connection.is_open
> always returns True...
>
> Anyone an idea how to deal with this?
>
> Cheers,
>
> J
>
> #!/usr/bin/python
>
> import pika
> from pika.adapters import SelectConnection
> from pika.adapters import BlockingConnection
> import time
>
> parameters = pika.ConnectionParameters(host='sandbox')
> connection = BlockingConnection(parameters)
>
> channel = connection.channel()
>
> channel.queue_declare(queue="test", durable=True, exclusive=False,
> auto_delete=False)
>
> time.sleep(10)
> #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!",
>
> properties=pika.BasicProperties(content_type="text/plain", delivery_mode=1))
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
More information about the rabbitmq-discuss
mailing list