summaryrefslogtreecommitdiff
path: root/python/qpid/client.py
diff options
context:
space:
mode:
authorAlan Conway <aconway@apache.org>2007-03-19 19:39:55 +0000
committerAlan Conway <aconway@apache.org>2007-03-19 19:39:55 +0000
commita96bf8ba7ce40d12ee4b3f85002133e1738225a4 (patch)
tree13db6eefd1120c228c11ff7d94a500bbbd4d1289 /python/qpid/client.py
parent27e6ef93eea10d1aeb7ca6a6a37926aa5f85c380 (diff)
downloadqpid-python-a96bf8ba7ce40d12ee4b3f85002133e1738225a4.tar.gz
Merged revisions 504590 via svnmerge from
https://svn.apache.org/repos/asf/incubator/qpid/branches/qpid.0-9 ........ r504590 | gsim | 2007-02-07 10:36:01 -0500 (Wed, 07 Feb 2007) | 6 lines Added support for receiving and sending of references Added asynchronous mode to channels (responses can be tracked via a future, rather than blocking on each request) Added ability to override server suggested connection tune params Added two tests for reference functionality (more to follow) ........ git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@520061 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/qpid/client.py')
-rw-r--r--python/qpid/client.py31
1 files changed, 28 insertions, 3 deletions
diff --git a/python/qpid/client.py b/python/qpid/client.py
index 20d1093878..ea6aa7901a 100644
--- a/python/qpid/client.py
+++ b/python/qpid/client.py
@@ -28,6 +28,7 @@ from delegate import Delegate
from connection import Connection, Frame, connect
from spec import load
from queue import Queue
+from reference import ReferenceId, References
class Client:
@@ -69,13 +70,14 @@ class Client:
self.lock.release()
return q
- def start(self, response, mechanism="AMQPLAIN", locale="en_US"):
+ def start(self, response, mechanism="AMQPLAIN", locale="en_US", tune_params=None):
self.mechanism = mechanism
self.response = response
self.locale = locale
+ self.tune_params = tune_params
self.conn = Connection(connect(self.host, self.port), self.spec)
- self.peer = Peer(self.conn, ClientDelegate(self))
+ self.peer = Peer(self.conn, ClientDelegate(self), self.opened)
self.conn.init()
self.peer.start()
@@ -85,6 +87,9 @@ class Client:
def channel(self, id):
return self.peer.channel(id)
+ def opened(self, ch):
+ ch.references = References()
+
class ClientDelegate(Delegate):
def __init__(self, client):
@@ -97,9 +102,29 @@ class ClientDelegate(Delegate):
locale=self.client.locale)
def connection_tune(self, ch, msg):
- msg.tune_ok(*msg.frame.args)
+ if self.client.tune_params:
+ #todo: just override the params, i.e. don't require them
+ # all to be included in tune_params
+ msg.tune_ok(**self.client.tune_params)
+ else:
+ msg.tune_ok(*msg.frame.args)
self.client.started.set()
+ def message_transfer(self, ch, msg):
+ if isinstance(msg.body, ReferenceId):
+ self.client.queue(msg.destination).put(ch.references.get(msg.body.id))
+ else:
+ self.client.queue(msg.destination).put(msg)
+
+ def message_open(self, ch, msg):
+ ch.references.open(msg.reference)
+
+ def message_close(self, ch, msg):
+ ch.references.close(msg.reference)
+
+ def message_append(self, ch, msg):
+ ch.references.get(msg.reference).append(msg.bytes)
+
def basic_deliver(self, ch, msg):
self.client.queue(msg.consumer_tag).put(msg)