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 | 79c1bec8dd57875c2dca25bcfa500ecbf19aab5e (patch) | |
tree | 45c3a6e3e3d17d6db5220576c53d031be175fd82 /python | |
parent | 62050e06a6dbe1fa22b109a9f9aea0d7d38c64ed (diff) | |
download | qpid-python-79c1bec8dd57875c2dca25bcfa500ecbf19aab5e.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/qpid@605599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python')
-rw-r--r-- | python/examples/pubsub/topic_publisher.py (renamed from python/examples/pubsub/topic_producer.py) | 26 | ||||
-rw-r--r-- | python/examples/pubsub/topic_subscriber.py (renamed from python/examples/pubsub/topic_consumer.py) | 14 |
2 files changed, 15 insertions, 25 deletions
diff --git a/python/examples/pubsub/topic_producer.py b/python/examples/pubsub/topic_publisher.py index c3b13cd82c..1ff983b315 100644 --- a/python/examples/pubsub/topic_producer.py +++ b/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/python/examples/pubsub/topic_consumer.py b/python/examples/pubsub/topic_subscriber.py index afe8bba91e..08682f0674 100644 --- a/python/examples/pubsub/topic_consumer.py +++ b/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" |