Created
April 30, 2012 19:53
-
-
Save khomenko/2562165 to your computer and use it in GitHub Desktop.
simple rabbitmq debug firehose consumer
This file contains 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 | |
import sys | |
""" | |
turn firehose on with "rabbitmqctl trace_on" | |
""" | |
if __name__ == "__main__": | |
connection = pika.BlockingConnection(pika.ConnectionParameters( | |
host='localhost')) | |
channel = connection.channel() | |
queue_name = "firehose" | |
result = channel.queue_declare(queue=queue_name, exclusive=False) | |
channel.queue_bind(exchange='amq.rabbitmq.trace', | |
queue=queue_name, | |
routing_key="#") | |
print ' [*] Waiting for logs. To exit press CTRL+C' | |
def callback(ch, method, properties, body): | |
print " [x] %r:%r:%r:%r" % ( | |
method.routing_key, | |
properties.headers["node"], | |
properties.headers["routing_keys"], | |
body, | |
) | |
channel.basic_consume(callback, | |
queue=queue_name, | |
no_ack=True) | |
channel.start_consuming() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment