Skip to content
Snippets Groups Projects
Commit 0a126066 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Add agent template

parent cafdc8e0
No related branches found
No related tags found
2 merge requests!23Feat resolve uid gid,!18Redesign RabbitMQ
#!/usr/bin/env python
import sys
import json
from rc_rmq import RCRMQ
task = 'task_name'
# Instantiate rabbitmq object
rc_rmq = RCRMQ({'exchange': 'RegUsr', 'exchange_type': 'topic'})
# Define your callback function
def on_message(ch, method, properties, body):
# Retrieve routing key
routing_key = method.routing_key
# Retrieve message
msg = json.loads(body)
# Do Something
print('[{}]: Callback called.'.format(task))
# Acknowledge message
ch.basic_ack(delivery_tag=method.delivery_tag)
print("Start listening to queue: {}".format(task))
rc_rmq.start_consume({
'queue': task, # Define your Queue name
'routing_key': "#", # Define your routing key
'cb': on_message # Pass in callback function you just define
})
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment