[rabbitmq-discuss] RabbitMQ consumer cancel notification callback is not called
akhil.pillai at gslab.com
akhil.pillai at gslab.com
Tue Feb 4 11:21:09 GMT 2014
On Thursday, January 30, 2014 1:22:24 PM UTC+5:30, akhil.... at gslab.com
wrote:
>
> Hi All,
>
> I am working on RabbitMQ HA cluster . I want my client to connect to
> slave node when the master node goes down.
> I am trying to achieve this using consumer cancel notification.
> I am using python amqp 1.4.2 library . I have set the capability
> 'consumer_cancel_notify' as True in client_properties.
> In basic_consume() I have passed a callback function to on_cancel
> parameter. But this callback is not called when master goes down.
>
> Can someone tell where I am going wrong.
>
> Following is my code :
>
> import amqp
>
> # this is the callback function to receive the messages published to the
> queue
> def myCallback(message):
> print "messsage received",message.body
>
> # this is the callback Function for consumer cancel notification
> def cancelCallback():
> print "cancelCallback called"
>
>
> cpDict = {"capabilities":{"consumer_cancel_notify": True, },}
> con = amqp.Connection(host ="localhost:5672",userid
> ="guest",password="guest",client_properties=cpDict)
> channel = con.channel()
> channel.exchange_declare(exchange="exchange1",type='direct', durable=True,
> auto_delete=False)
> channel.queue_declare(queue="bm2_execQ", durable=True,exclusive=True,
> auto_delete=False)
> channel.queue_bind(queue="bm2_execQ",exchange="exchange1",
> routing_key="bm2_execQ")
> channel.basic_consume(queue="bm2_execQ",callback=myCallback,
> consumer_tag="bm2_tag",on_cancel=cancelCallback)
>
> msg = amqp.Message("hi")
> msg.properties["content_type"] = "text/plain"
> msg.properties["delivery_mode"] = 2
>
> channel.basic_publish(msg,"exchange1","bm2_execQ")
>
> while True :
> channel.wait()
>
Can somebody please help me on this?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140204/a5d4a050/attachment.html>
More information about the rabbitmq-discuss
mailing list