From 5707747868639129b7755b39fbf975f5cb866340 Mon Sep 17 00:00:00 2001 From: "Bo-Chun Louis Chen(VM)" <louistw@uab.edu> Date: Sat, 22 Feb 2020 04:51:56 +0000 Subject: [PATCH] Update README --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index 97bfe2b..4a18b9e 100644 --- a/README.md +++ b/README.md @@ -27,4 +27,21 @@ rc_rmq.publish_msg({ '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', + 'cb': callback_function +}) + ``` -- GitLab