Skip to content

Commit e606ca6

Browse files
committed
Merge branch 'master' into bug23571
2 parents 5aab364 + dc869aa commit e606ca6

File tree

4 files changed

+54
-2
lines changed

4 files changed

+54
-2
lines changed

python/emit_log_topic.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env python
2+
import pika
3+
import sys
4+
5+
connection = pika.AsyncoreConnection(pika.ConnectionParameters(
6+
host='localhost'))
7+
channel = connection.channel()
8+
9+
channel.exchange_declare(exchange='topic_logs',
10+
type='topic')
11+
12+
routing_key = sys.argv[1] if len(sys.argv) > 1 else 'anonymous.info'
13+
message = ' '.join(sys.argv[2:]) or 'Hello World!'
14+
channel.basic_publish(exchange='topic_logs',
15+
routing_key=routing_key,
16+
body=message)
17+
print " [x] Sent %r:%r" % (routing_key, message)
18+
connection.close()

python/receive_logs_direct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
channel.exchange_declare(exchange='direct_logs',
1010
type='direct')
1111

12-
result = channel.queue_declare(auto_delete=True)
12+
result = channel.queue_declare(exclusive=True)
1313
queue_name = result.queue
1414

1515
severities = sys.argv[1:]

python/receive_logs_topic.py

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/usr/bin/env python
2+
import pika
3+
import sys
4+
5+
connection = pika.AsyncoreConnection(pika.ConnectionParameters(
6+
host='localhost'))
7+
channel = connection.channel()
8+
9+
channel.exchange_declare(exchange='topic_logs',
10+
type='topic')
11+
12+
result = channel.queue_declare(exclusive=True)
13+
queue_name = result.queue
14+
15+
binding_keys = sys.argv[1:]
16+
if not binding_keys:
17+
print >> sys.stderr, "Usage: %s [binding_key]..." % (sys.argv[0],)
18+
sys.exit(1)
19+
20+
for binding_key in binding_keys:
21+
channel.queue_bind(exchange='topic_logs',
22+
queue=queue_name,
23+
routing_key=binding_key)
24+
25+
print ' [*] Waiting for logs. To exit press CTRL+C'
26+
27+
def callback(ch, method, header, body):
28+
print " [x] %r:%r" % (method.routing_key, body,)
29+
30+
channel.basic_consume(callback,
31+
queue=queue_name,
32+
no_ack=True)
33+
34+
pika.asyncore_loop()

python/rpc_client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def __init__(self):
99

1010
self.channel = self.connection.channel()
1111

12-
result = self.channel.queue_declare(auto_delete=True)
12+
result = self.channel.queue_declare(exclusive=True)
1313
self.callback_queue = result.queue
1414

1515
self.requests = {}

0 commit comments

Comments
 (0)