28 lines
705 B
Python
Executable File
28 lines
705 B
Python
Executable File
#!/usr/bin/env python
|
|
import pika
|
|
|
|
connection = pika.AsyncoreConnection(pika.ConnectionParameters(
|
|
host='127.0.0.1',
|
|
credentials=pika.PlainCredentials('guest', 'guest')))
|
|
channel = connection.channel()
|
|
|
|
channel.exchange_declare(exchange='logs',
|
|
type='fanout')
|
|
|
|
result = channel.queue_declare(auto_delete=True)
|
|
queue_name = result.queue
|
|
|
|
channel.queue_bind(exchange='logs',
|
|
queue=queue_name)
|
|
|
|
print ' [*] Waiting for logs. To exit press CTRL+C'
|
|
|
|
def callback(ch, method, header, body):
|
|
print " [x] %r" % (body,)
|
|
|
|
channel.basic_consume(callback,
|
|
queue=queue_name,
|
|
no_ack=True)
|
|
|
|
pika.asyncore_loop()
|