diff options
| author | Gordon Sim <gsim@apache.org> | 2007-12-19 16:01:28 +0000 |
|---|---|---|
| committer | Gordon Sim <gsim@apache.org> | 2007-12-19 16:01:28 +0000 |
| commit | a8cfd6ce0dd80f4e2980f48282d074aef53f8132 (patch) | |
| tree | cb91e40edeb86443382bdbf071270f86eea8f9a3 /qpid/python/examples | |
| parent | b4953dd742da8c4729632ce2b6d99ebb0c8f9b32 (diff) | |
| download | qpid-python-a8cfd6ce0dd80f4e2980f48282d074aef53f8132.tar.gz | |
File rename to better fit the pubsub nomenclature (from jrobie@redhat.com)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@605599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/python/examples')
| -rw-r--r-- | qpid/python/examples/pubsub/topic_publisher.py (renamed from qpid/python/examples/pubsub/topic_producer.py) | 26 | ||||
| -rw-r--r-- | qpid/python/examples/pubsub/topic_subscriber.py (renamed from qpid/python/examples/pubsub/topic_consumer.py) | 14 |
2 files changed, 15 insertions, 25 deletions
diff --git a/qpid/python/examples/pubsub/topic_producer.py b/qpid/python/examples/pubsub/topic_publisher.py index c3b13cd82c..1ff983b315 100644 --- a/qpid/python/examples/pubsub/topic_producer.py +++ b/qpid/python/examples/pubsub/topic_publisher.py @@ -1,6 +1,6 @@ #!/usr/bin/env python """ - topic_producer.py + topic_publisher.py This is a simple AMQP publisher application that uses a Topic exchange. The publisher specifies the routing key @@ -37,10 +37,6 @@ session.session_open() # topic exchange. The routing keys are "usa.news", "usa.weather", # "europe.news", and "europe.weather". -final = "That's all, folks!" - -# We'll use the same routing key for all messages in the loop, and -# also for the terminating message. # usa.news @@ -49,22 +45,13 @@ for i in range(5): message["routing_key"] = "usa.news" session.message_transfer(destination="amq.topic", content=message) -message = Content(final) -message["routing_key"] = "usa.news" -session.message_transfer(destination="amq.topic", content=message) - # usa.weather - for i in range(5): message = Content("message " + str(i)) message["routing_key"] = "usa.weather" session.message_transfer(destination="amq.topic", content=message) -message = Content(final) -message["routing_key"] = "usa.weather" -session.message_transfer(destination="amq.topic", content=message) - # europe.news for i in range(5): @@ -72,11 +59,6 @@ for i in range(5): message["routing_key"] = "europe.news" session.message_transfer(destination="amq.topic", content=message) -message = Content(final) -message["routing_key"] = "europe.news" -session.message_transfer(destination="amq.topic", content=message) - - # europe.weather for i in range(5): @@ -84,8 +66,10 @@ for i in range(5): message["routing_key"] = "europe.weather" session.message_transfer(destination="amq.topic", content=message) -message = Content(final) -message["routing_key"] = "europe.weather" +# Signal termination + +message = Content("That's all, folks!") +message["routing_key"] = "control" session.message_transfer(destination="amq.topic", content=message) diff --git a/qpid/python/examples/pubsub/topic_consumer.py b/qpid/python/examples/pubsub/topic_subscriber.py index afe8bba91e..08682f0674 100644 --- a/qpid/python/examples/pubsub/topic_consumer.py +++ b/qpid/python/examples/pubsub/topic_subscriber.py @@ -1,10 +1,9 @@ #!/usr/bin/env python """ - topic_consumer.py + topic_subscriber.py - This AMQP client reads all messages from the - "news", "weather", "usa", and "europe" queues - created and bound by config_topic_exchange.py. + This subscriber creates private queues and binds them + to the topics "usa.#", "europe.#", "#.news", and "#.weather". """ import base64 @@ -100,6 +99,13 @@ session.queue_bind(exchange="amq.topic", queue=weather, routing_key="#.weather") session.queue_bind(exchange="amq.topic", queue=usa, routing_key="usa.#") session.queue_bind(exchange="amq.topic", queue=europe, routing_key="europe.#") +# Bind each queue to the control queue so we know when to stop + +session.queue_bind(exchange="amq.topic", queue=news, routing_key="control") +session.queue_bind(exchange="amq.topic", queue=weather, routing_key="control") +session.queue_bind(exchange="amq.topic", queue=usa, routing_key="control") +session.queue_bind(exchange="amq.topic", queue=europe, routing_key="control") + # Remind the user to start the topic producer print "Queues create - please start the topic producer" |
