Permalink
Browse files

Merge branch 'master' into bug23571

  • Loading branch information...
2 parents 5aab364 + dc869aa commit e606ca650b74a7e4fe89cef35908ab341c6eb70d @majek majek committed Dec 14, 2010
Showing with 54 additions and 2 deletions.
  1. +18 −0 python/emit_log_topic.py
  2. +1 −1 python/receive_logs_direct.py
  3. +34 −0 python/receive_logs_topic.py
  4. +1 −1 python/rpc_client.py
@@ -0,0 +1,18 @@
+#!/usr/bin/env python
+import pika
+import sys
+
+connection = pika.AsyncoreConnection(pika.ConnectionParameters(
+ host='localhost'))
+channel = connection.channel()
+
+channel.exchange_declare(exchange='topic_logs',
+ type='topic')
+
+routing_key = sys.argv[1] if len(sys.argv) > 1 else 'anonymous.info'
+message = ' '.join(sys.argv[2:]) or 'Hello World!'
+channel.basic_publish(exchange='topic_logs',
+ routing_key=routing_key,
+ body=message)
+print " [x] Sent %r:%r" % (routing_key, message)
+connection.close()
@@ -9,7 +9,7 @@
channel.exchange_declare(exchange='direct_logs',
type='direct')
-result = channel.queue_declare(auto_delete=True)
+result = channel.queue_declare(exclusive=True)
queue_name = result.queue
severities = sys.argv[1:]
@@ -0,0 +1,34 @@
+#!/usr/bin/env python
+import pika
+import sys
+
+connection = pika.AsyncoreConnection(pika.ConnectionParameters(
+ host='localhost'))
+channel = connection.channel()
+
+channel.exchange_declare(exchange='topic_logs',
+ type='topic')
+
+result = channel.queue_declare(exclusive=True)
+queue_name = result.queue
+
+binding_keys = sys.argv[1:]
+if not binding_keys:
+ print >> sys.stderr, "Usage: %s [binding_key]..." % (sys.argv[0],)
+ sys.exit(1)
+
+for binding_key in binding_keys:
+ channel.queue_bind(exchange='topic_logs',
+ queue=queue_name,
+ routing_key=binding_key)
+
+print ' [*] Waiting for logs. To exit press CTRL+C'
+
+def callback(ch, method, header, body):
+ print " [x] %r:%r" % (method.routing_key, body,)
+
+channel.basic_consume(callback,
+ queue=queue_name,
+ no_ack=True)
+
+pika.asyncore_loop()
@@ -9,7 +9,7 @@ def __init__(self):
self.channel = self.connection.channel()
- result = self.channel.queue_declare(auto_delete=True)
+ result = self.channel.queue_declare(exclusive=True)
self.callback_queue = result.queue
self.requests = {}

0 comments on commit e606ca6

Please sign in to comment.