From 0a12606621b536bd105ef462e33496e6764cf86f Mon Sep 17 00:00:00 2001
From: "Bo-Chun Louis Chen(VM)" <louistw@uab.edu>
Date: Thu, 19 Mar 2020 20:35:22 +0000
Subject: [PATCH] Add agent template

---
 agent_template.py | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)
 create mode 100644 agent_template.py

diff --git a/agent_template.py b/agent_template.py
new file mode 100644
index 0000000..c6e7223
--- /dev/null
+++ b/agent_template.py
@@ -0,0 +1,32 @@
+#!/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
+})
-- 
GitLab