Skip to content
Snippets Groups Projects
Bo-Chun Louis Chen's avatar
Bo-Chun Chen authored
Trim Trailing Whitespace.................................................Failed
- hook id: trailing-whitespace
- exit code: 1
- files were modified by this hook

Fixing prod_rmq_agents/group_member.py

Fix End of Files.........................................................Failed
- hook id: end-of-file-fixer
- exit code: 1
- files were modified by this hook

Fixing prod_rmq_agents/group_member.py

Check Yaml...........................................(no files to check)Skipped
black....................................................................Failed
- hook id: black
- files were modified by this hook

reformatted prod_rmq_agents/group_member.py

All done!  🍰 
1 file reformatted.

flake8...................................................................Failed
- hook id: flake8
- exit code: 1

prod_rmq_agents/group_member.py:33:80: E501 line too long (144 > 79 characters)
prod_rmq_agents/group_member.py:35:80: E501 line too long (139 > 79 characters)
prod_rmq_agents/group_member.py:51:80: E501 line too long (137 > 79 characters)
prod_rmq_agents/group_member.py:53:80: E501 line too long (132 > 79 characters)
prod_rmq_agents/group_member.py:69:80: E501 line too long (102 > 79 characters)
cc8f9504

rabbitmq_agents

This repo keeps different rabbitmq agents that help in account creation on OHPC system.

It has 2 branches develop and production , that houses agents based on where they are launched

Using RCRMQ class

  • First, rename rabbit_config.py.example to rabbit_config.py

  • Modify config file, at least the Password needs to be your own passwod

  • In your code:

# import the class
from rc_rmq import RCRMQ

# instantiate an instance
rc_rmq = RCRMQ({'exchange': 'RegUsr'})

# publish a message to message queue
rc_rmq.publish_msg({
  'routing_key': 'your_key',
  'msg': {
    'type': 'warning',
    'content': 'this is warning'
  }
})

# to consume message from a queue
# you have to first define callback function
# with parameters: channel, method, properties, body
def callback_function(ch, method, properties, body):
  msg = json.loads(body)
  print("get msg: {}".format(msg['username')

  # this will stop the consumer
  rc_rmq.stop_consumer()

# start consume messagre from queue with callback function
rc_rmq.start_consume({
  'queue': 'queue_name',
  'routing_key: 'your_key',
  'cb': callback_function
})

# don't forget to close connection
rc_rmq.disconnect()

Account creation flowchart

Account creation flowchart