qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r..@apache.org
Subject svn commit: r891537 - in /qpid/trunk/qpid/python/qpid: driver.py tests/messaging.py
Date Thu, 17 Dec 2009 04:58:33 GMT
Author: rhs
Date: Thu Dec 17 04:58:31 2009
New Revision: 891537

URL: http://svn.apache.org/viewvc?rev=891537&view=rev
Log:
QPID-2287: added an address option for declaring queues with multiple bindings

Modified:
    qpid/trunk/qpid/python/qpid/driver.py
    qpid/trunk/qpid/python/qpid/tests/messaging.py

Modified: qpid/trunk/qpid/python/qpid/driver.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/driver.py?rev=891537&r1=891536&r2=891537&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/driver.py (original)
+++ qpid/trunk/qpid/python/qpid/driver.py Thu Dec 17 04:58:31 2009
@@ -605,6 +605,7 @@
       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 @@
     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):

Modified: qpid/trunk/qpid/python/qpid/tests/messaging.py
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/python/qpid/tests/messaging.py?rev=891537&r1=891536&r2=891537&view=diff
==============================================================================
--- qpid/trunk/qpid/python/qpid/tests/messaging.py (original)
+++ qpid/trunk/qpid/python/qpid/tests/messaging.py Thu Dec 17 04:58:31 2009
@@ -642,6 +642,28 @@
     # 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"



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message