[rabbitmq-discuss] RabbitMQ consumer cancel notification callback is not called
Akhil Pillai
akhil.pillai at gslab.com
Thu Jan 30 08:02:31 GMT 2014
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.
Thanks,
Akhil
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()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20140130/72594816/attachment.html>
More information about the rabbitmq-discuss
mailing list