Skip to content
Snippets Groups Projects
Commit 52398bd5 authored by Eesaan Atluri's avatar Eesaan Atluri
Browse files

RabbitMQ agent for event logging user self reg app

parent 495e522a
No related branches found
No related tags found
6 merge requests!147Merge previous default branch feat-cod-rmq into main,!85kill nginx process running under user from login node,!51Fix acct create wait,!32Feat user reg event logger,!39WIP:Feat cod rmq,!38WIP: Feat cod rmq
#!/usr/bin/env python
import sys
import json
from rc_rmq import RCRMQ
task = 'user_reg_event_log'
# Instantiate rabbitmq object
rc_rmq = RCRMQ({'exchange': 'RegUsr', 'exchange_type': 'topic'})
# Define your callback function
def log_user_reg_events(ch, method, properties, body):
# Retrieve routing key
routing_key = method.routing_key
print(routing_key)
# Retrieve message
msg = json.loads(body)
print(msg)
# 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': log_user_reg_events # 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