Skip to content
Snippets Groups Projects
diedpigs's avatar
Bo-Chun Chen authored
* Remove some variables from the RCRMQ class

The previous design was base on these assumptions:
  RCRMQ instance only need to do either publish or consume
  RCRMQ instance only need to interact with one single queue

However, in order to perform RPC-like call, an instance will need to do both
publish and consume. In addition, publish and consume are not necessary
to the same queue. So, save queue name as single variable inside the
instance is not viable anymore.

* Add exclusive queue support

* Check connection before bind queue

* Add auto-generate queue support

* Make bind queue optional when start consume

* Add properties support when publish msg

* Add user_state agent

* Add check_state in rc_util

* Add update_state in rc_util

* Add no-account when no hit in db

* Move valid state into config file

* Add user auth example

* Add migration flag

During the first phase, e.g. not all of users are in the user_state DB,
  using alternative method, getnet passwd, to see if user is an existing
  user.

* Update user state when using alternative lookup

* Allow no reply-to message to the user_state

* Add path for venv packages

* Fix typo

* Remove sys path to venv

* Fix condition for migration phase code

* Drop output from subprocess

* Move user_auth to top level

* Add default state as variable
933285e5

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()