From 071726a471de25d6692840bb546ededddca36772 Mon Sep 17 00:00:00 2001 From: Marc Partensky Date: Fri, 25 Feb 2022 02:06:20 +0100 Subject: [PATCH] receive.py wip --- receive.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 receive.py diff --git a/receive.py b/receive.py new file mode 100755 index 0000000..b0f26c4 --- /dev/null +++ b/receive.py @@ -0,0 +1,25 @@ +#!/usr/bin/env python +"""Consummer of the queue.""" + +import sys, os +import pika + +HOST = os.environ["HOST"] + +def callback(ch, method, properties, body): + """Called when a new event is received.""" + print(" [x] Received %r" % body) + +def main(): + """Main function.""" + connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) + channel = connection.channel() + + channel.queue_declare(queue='push') + channel.basic_consume(queue='push', on_message_callback=callback, auto_ack=True) + + print(' [*] Waiting for messages. To exit press CTRL+C') + channel.start_consuming() + +if __name__ == '__main__': + main()