summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2007-12-05 15:19:45 +0000
committerGordon Sim <gsim@apache.org>2007-12-05 15:19:45 +0000
commit387a53a7dd18dd0bd3dd4a36b2a600cfbd60f249 (patch)
tree94ea297ec735e0e3fd6598eaf08ecc3be70e38b7
parentb95f79c2f01db4aff1124522d6655eb745079f29 (diff)
downloadqpid-python-387a53a7dd18dd0bd3dd4a36b2a600cfbd60f249.tar.gz
Updates to examples from jonathan.robie@redhat.com
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@601358 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/python/examples/direct/config_direct_exchange.py4
-rw-r--r--qpid/python/examples/direct/direct_consumer.py2
-rw-r--r--qpid/python/examples/fanout/config_fanout_exchange.py2
-rw-r--r--qpid/python/examples/fanout/fanout_producer.py1
-rw-r--r--qpid/python/examples/pubsub/topic_consumer.py14
-rw-r--r--qpid/python/examples/pubsub/topic_producer.py4
-rw-r--r--qpid/python/examples/request-response/client.py15
-rw-r--r--qpid/python/examples/request-response/server.py5
8 files changed, 18 insertions, 29 deletions
diff --git a/qpid/python/examples/direct/config_direct_exchange.py b/qpid/python/examples/direct/config_direct_exchange.py
index 45af6f63b9..e64ad678b8 100644
--- a/qpid/python/examples/direct/config_direct_exchange.py
+++ b/qpid/python/examples/direct/config_direct_exchange.py
@@ -49,9 +49,5 @@ session.queue_bind(exchange="amq.direct", queue="message_queue", routing_key="ro
#----- Cleanup ---------------------------------------------
-# Clean up before exiting so there are no open threads.
-#
-# Close Channel 1.
-# Close the connection using Channel 0, which is used for all connection methods.
session.session_close()
diff --git a/qpid/python/examples/direct/direct_consumer.py b/qpid/python/examples/direct/direct_consumer.py
index 4e50dfbc2a..38b1ba30a0 100644
--- a/qpid/python/examples/direct/direct_consumer.py
+++ b/qpid/python/examples/direct/direct_consumer.py
@@ -72,4 +72,4 @@ message.complete(cumulative=True)
# Clean up before exiting so there are no open threads.
#
-# session.session_close()
+session.session_close()
diff --git a/qpid/python/examples/fanout/config_fanout_exchange.py b/qpid/python/examples/fanout/config_fanout_exchange.py
index 6eef1b94e3..3315f5bc14 100644
--- a/qpid/python/examples/fanout/config_fanout_exchange.py
+++ b/qpid/python/examples/fanout/config_fanout_exchange.py
@@ -50,5 +50,5 @@ session.queue_bind(exchange="amq.fanout", queue="message_queue")
#----- Cleanup ---------------------------------------------
# Clean up before exiting so there are no open threads.
-# channel.session_close()
+session.session_close()
diff --git a/qpid/python/examples/fanout/fanout_producer.py b/qpid/python/examples/fanout/fanout_producer.py
index 42570ed510..92ca7b7ec0 100644
--- a/qpid/python/examples/fanout/fanout_producer.py
+++ b/qpid/python/examples/fanout/fanout_producer.py
@@ -46,4 +46,3 @@ session.message_transfer(destination="amq.fanout", content=message)
# Clean up before exiting so there are no open threads.
session.session_close()
-
diff --git a/qpid/python/examples/pubsub/topic_consumer.py b/qpid/python/examples/pubsub/topic_consumer.py
index 5db04573f8..afe8bba91e 100644
--- a/qpid/python/examples/pubsub/topic_consumer.py
+++ b/qpid/python/examples/pubsub/topic_consumer.py
@@ -74,15 +74,16 @@ client = Client(host, port, spec)
client.start({"LOGIN": user, "PASSWORD": password})
session = client.session()
-session = session.session_open() # keep the session object, we'll need the session id
+session_info = session.session_open()
+session_id = session_info.session_id
#----- Main Body -- ----------------------------------------
-news = "news" + base64.urlsafe_b64encode(session.session_id)
-weather = "weather" + base64.urlsafe_b64encode(session.session_id)
-usa = "usa" + base64.urlsafe_b64encode(session.session_id)
-europe = "europe" + base64.urlsafe_b64encode(session.session_id)
+news = "news" + base64.urlsafe_b64encode(session_id)
+weather = "weather" + base64.urlsafe_b64encode(session_id)
+usa = "usa" + base64.urlsafe_b64encode(session_id)
+europe = "europe" + base64.urlsafe_b64encode(session_id)
session.queue_declare(queue=news, exclusive=True)
session.queue_declare(queue=weather, exclusive=True)
@@ -113,8 +114,5 @@ dump_queue(client, europe)
#----- Cleanup ------------------------------------------------
# Clean up before exiting so there are no open threads.
-#
-# Close Channel 1.
session.session_close()
-
diff --git a/qpid/python/examples/pubsub/topic_producer.py b/qpid/python/examples/pubsub/topic_producer.py
index 5f8372e7ba..c3b13cd82c 100644
--- a/qpid/python/examples/pubsub/topic_producer.py
+++ b/qpid/python/examples/pubsub/topic_producer.py
@@ -92,9 +92,5 @@ session.message_transfer(destination="amq.topic", content=message)
#----- Cleanup --------------------------------------------
# Clean up before exiting so there are no open threads.
-#
-# Close Channel 1.
-
session.session_close()
-
diff --git a/qpid/python/examples/request-response/client.py b/qpid/python/examples/request-response/client.py
index 23e9310509..bc0cf8a55a 100644
--- a/qpid/python/examples/request-response/client.py
+++ b/qpid/python/examples/request-response/client.py
@@ -22,7 +22,7 @@ def dump_queue(client, queue_name):
consumer_tag = queue_name # Use the queue name as the consumer tag - need a unique tag
queue = client.queue(consumer_tag)
- # Call basic_consume() to tell the broker to deliver messages
+ # Call message_subscribe() to tell the broker to deliver messages
# from the AMQP queue to a local client queue. The broker will
# start delivering messages as soon as basic_consume() is called.
@@ -46,8 +46,8 @@ def dump_queue(client, queue_name):
# Messages are not removed from the queue until they
- # are acknowledged. Using multiple=True, all messages
- # in the channel up to and including the one identified
+ # are acknowledged. Using cumulative=True, all messages
+ # in the session up to and including the one identified
# by the delivery tag are acknowledged. This is more efficient,
# because there are fewer network round-trips.
@@ -71,8 +71,11 @@ spec = qpid.spec.load(amqp_spec)
client = Client(host, port, spec)
client.start({"LOGIN": user, "PASSWORD": password})
+# Open the session. Save the session id.
+
session = client.session()
-session.session_open()
+session_info = session.session_open()
+session_id = session_info.session_id
#----- Main Body -- ----------------------------------------
@@ -80,7 +83,7 @@ session.session_open()
# same string as the name of the queue and the name of the routing
# key.
-replyTo = "ReplyTo:" # + base64.urlsafe_b64encode(session.session_id)
+replyTo = "ReplyTo:" + base64.urlsafe_b64encode(session_id)
session.queue_declare(queue=replyTo, exclusive=True)
session.queue_bind(exchange="amq.direct", queue=replyTo, routing_key=replyTo)
@@ -109,4 +112,4 @@ dump_queue(client, replyTo)
# Clean up before exiting so there are no open threads.
-session.session_close()
+session.session_close()
diff --git a/qpid/python/examples/request-response/server.py b/qpid/python/examples/request-response/server.py
index dd81b419e8..28bfd5ee4a 100644
--- a/qpid/python/examples/request-response/server.py
+++ b/qpid/python/examples/request-response/server.py
@@ -41,7 +41,7 @@ client.start({"LOGIN": user, "PASSWORD": password})
# Open Channel 1 so we can use it to manage our queue.
session = client.session()
-session.session_open() # keep the session object, we'll need the session id
+session.session_open()
#----- Main Body -- ----------------------------------------
@@ -82,8 +82,5 @@ while True:
#----- Cleanup ------------------------------------------------
# Clean up before exiting so there are no open threads.
-#
-# Close Channel 1.
session.session_close()
-