receive.py wip

This commit is contained in:
2022-02-25 02:06:20 +01:00
parent 78a97db320
commit 071726a471
Executable
+25
View File
@@ -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()