summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2009-12-17 04:58:31 +0000
committerRafael H. Schloming <rhs@apache.org>2009-12-17 04:58:31 +0000
commitdce77f3f14bc9b11999f2a38e5b005d77bc37307 (patch)
tree42ff138b6102574355db3ef3200658cc30bedd74
parent59c274c2a1965255507d15df1fe028453152056e (diff)
downloadqpid-python-dce77f3f14bc9b11999f2a38e5b005d77bc37307.tar.gz
QPID-2287: added an address option for declaring queues with multiple bindings
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@891537 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/python/qpid/driver.py14
-rw-r--r--qpid/python/qpid/tests/messaging.py22
2 files changed, 35 insertions, 1 deletions
diff --git a/qpid/python/qpid/driver.py b/qpid/python/qpid/driver.py
index 3cc69921bb..e31276ad7b 100644
--- a/qpid/python/qpid/driver.py
+++ b/qpid/python/qpid/driver.py
@@ -605,6 +605,7 @@ class Driver:
cmd = ExchangeDeclare(exchange=name, durable=durable)
elif type == "queue":
cmd = QueueDeclare(queue=name, durable=durable)
+ bindings = xprops.pop("bindings", [])
else:
return ("unrecognized type, must be topic or queue: %s" % type,)
@@ -621,9 +622,20 @@ class Driver:
else:
subtype = None
+ cmds = [cmd]
+ if type == "queue":
+ for b in bindings:
+ try:
+ n, s, o = address.parse(b)
+ except address.ParseError, e:
+ return (e,)
+ cmds.append(ExchangeBind(name, n, s, o))
+
+ for c in cmds[:-1]:
+ sst.write_cmd(c)
def do_action():
action(type, subtype)
- sst.write_cmd(cmd, do_action)
+ sst.write_cmd(cmds[-1], do_action)
def delete(self, sst, name, action):
def do_delete(er, qr):
diff --git a/qpid/python/qpid/tests/messaging.py b/qpid/python/qpid/tests/messaging.py
index cbfbc5a56d..f2a270192e 100644
--- a/qpid/python/qpid/tests/messaging.py
+++ b/qpid/python/qpid/tests/messaging.py
@@ -642,6 +642,28 @@ class AddressTests(Base):
# XXX: need to figure out close after error
self.conn._remove_session(self.ssn)
+ def testBindings(self):
+ snd = self.ssn.sender("""
+test-bindings-queue; {
+ create: always,
+ delete: always,
+ node-properties: {
+ x-properties: {
+ bindings: ["amq.topic/a.#", "amq.direct/b", "amq.topic/c.*"]
+ }
+ }
+}
+""")
+ snd.send("one")
+ snd_a = self.ssn.sender("amq.topic/a.foo")
+ snd_b = self.ssn.sender("amq.direct/b")
+ snd_c = self.ssn.sender("amq.topic/c.bar")
+ snd_a.send("two")
+ snd_b.send("three")
+ snd_c.send("four")
+ rcv = self.ssn.receiver("test-bindings-queue")
+ self.drain(rcv, expected=["one", "two", "three", "four"])
+
NOSUCH_Q = "this-queue-should-not-exist"
UNPARSEABLE_ADDR = "name/subject; {bad options"
UNLEXABLE_ADDR = "\0x0\0x1\0x2\0x3"