From dce77f3f14bc9b11999f2a38e5b005d77bc37307 Mon Sep 17 00:00:00 2001 From: "Rafael H. Schloming" Date: Thu, 17 Dec 2009 04:58:31 +0000 Subject: 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 --- qpid/python/qpid/driver.py | 14 +++++++++++++- qpid/python/qpid/tests/messaging.py | 22 ++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) 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" -- cgit v1.2.1