コード例 #1
0
ファイル: work1.py プロジェクト: LotteryOne/rblearn
import util.conn as conn

connection = conn.getConnection('/')

channel = connection.channel()

channel.exchange_declare(exchange='topic_log', type='topic')

result = channel.queue_declare(exclusive=True)

queue_name = result.method.queue

serverities = ["*.json"]

for serverity in serverities:
    channel.queue_bind(exchange='topic_log',
                       queue=queue_name,
                       routing_key=serverity)

print(' [*] Waiting for messages. To exit press CTRL+C')

channel.basic_consume(conn.callback, queue=queue_name, no_ack=True)

channel.start_consuming()
コード例 #2
0
ファイル: pub.py プロジェクト: LotteryOne/rblearn
from util import conn

connection = conn.getConnection("/")
channel = connection.channel()
# fanout
result = channel.exchange_declare(exchange='level_log', type='direct')
print(result)

serverity = 'error'
message = "send " + serverity + " message"

channel.basic_publish(exchange='level_log',
                      routing_key=serverity,
                      body=message)

connection.close()