My python Code for basic_consume and callback method registration looks like below
#call back function to be called when we have any AMQP Message for any thread
def callback(ch, method, properties, body):
print json.dumps(xmltodict.parse(body.replace(">\n",">")))
#Function to start listening queue for a Vblock specified by objVCE
def listenEvents(objVCE):
credentials = pika.PlainCredentials(objVCE.strSTE,'')
connection = pika.BlockingConnection(pika.ConnectionParameters(host=objVCE.vBlock.getHost(),credentials=credentials, port=5672, ssl=False,virtual_host='/',socket_timeout=5000))
channel = connection.channel()
channel.queue_declare(queue='AMQPEvents', durable=True)
channel.queue_bind(exchange='fmdefaultexchange',queue='AMQPEvents',routing_key='*.*')
args = { "host":objVCE.vBlock.getHost() }
# Registering call back function to be called when any AMQP message is received
channel.basic_consume(callback,queue='AMQPEvents',no_ack=True, arguments=args)
I wanted to pass argument to callback function while registering callback function and that argument should be available in callback function whenever we received any events
I see that we have arguments parameter in basic_consume method, is that argument passed to call back function?
if so how do i receive it at callback function as definition for callback function will change?