Created
June 20, 2020 09:30
-
-
Save wh13371/9347a5c9252cd419ba44ca45de5c842f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import pika | |
credentials = pika.PlainCredentials('fizz', 'fizz') | |
parameters = pika.ConnectionParameters(host='?.?.?.?', | |
port=5672, credentials=credentials) | |
connection = pika.BlockingConnection(parameters) | |
channel = connection.channel() | |
channel.exchange_declare(exchange='logs', exchange_type='fanout') | |
result = channel.queue_declare(queue='fizz', exclusive=True) | |
queue_name = result.method.queue | |
channel.queue_bind(exchange='logs', queue=queue_name) | |
print(queue_name) | |
print(' [*] Waiting for logs. To exit press CTRL+C') | |
def callback(ch, method, properties, body): | |
print(" [x] %r" % body) | |
channel.basic_consume(queue=queue_name, on_message_callback=callback, auto_ack=True) | |
channel.start_consuming() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment