summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRafael H. Schloming <rhs@apache.org>2010-04-09 15:14:27 +0000
committerRafael H. Schloming <rhs@apache.org>2010-04-09 15:14:27 +0000
commitf328f8dfb20911b952f0c5551cc37c0b8d42576d (patch)
tree06822f9e5ef42755b86765ea16e76cae788764a8
parent0aaa340fa8c3b994790b355950d358af3b0979e2 (diff)
downloadqpid-python-f328f8dfb20911b952f0c5551cc37c0b8d42576d.tar.gz
updated reservations example to match latest changes
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@932454 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--qpid/python/examples/reservations/common.py4
-rwxr-xr-xqpid/python/examples/reservations/inventory16
-rwxr-xr-xqpid/python/examples/reservations/machine-agent10
-rwxr-xr-xqpid/python/examples/reservations/reserve5
4 files changed, 10 insertions, 25 deletions
diff --git a/qpid/python/examples/reservations/common.py b/qpid/python/examples/reservations/common.py
index 24e64beda4..12f07e1c92 100644
--- a/qpid/python/examples/reservations/common.py
+++ b/qpid/python/examples/reservations/common.py
@@ -52,13 +52,13 @@ class Dispatcher:
count = len(replies)
sequence = 1
- for r in replies:
+ for to, r in replies:
r.correlation_id = msg.correlation_id
r.properties["count"] = count
r.properties["sequence"] = sequence
sequence += 1
try:
- snd = session.sender(r.to)
+ snd = session.sender(to)
snd.send(r)
except SendError, e:
print e
diff --git a/qpid/python/examples/reservations/inventory b/qpid/python/examples/reservations/inventory
index 10c2034efc..0a49643e5f 100755
--- a/qpid/python/examples/reservations/inventory
+++ b/qpid/python/examples/reservations/inventory
@@ -20,7 +20,6 @@
import optparse, traceback
from qpid.messaging import *
-from qpid.util import URL
from qpid.log import enable, DEBUG, WARN
from common import *
@@ -42,11 +41,7 @@ if opts.verbose:
else:
enable("qpid", WARN)
-url = URL(opts.broker)
-conn = Connection.open(url.host, url.port or AMQP_PORT,
- username=url.user, password=url.password,
- reconnect=True,
- reconnect_delay=1)
+conn = Connection.establish(opts.broker, reconnect=True, reconnect_interval=1)
class Inventory(Dispatcher):
@@ -65,8 +60,7 @@ class Inventory(Dispatcher):
result = []
for id, (status, owner) in self.agents.items():
if match(id, patterns):
- r = Message(to = msg.reply_to,
- properties = {
+ r = Message(properties = {
"type": "status"
},
content = {
@@ -74,11 +68,11 @@ class Inventory(Dispatcher):
"status": status,
"owner": owner
})
- result.append(r)
+ result.append((msg.reply_to, r))
continue
if not result:
- result.append(Message(to = msg.reply_to,
- properties = {"type": "empty"}))
+ result.append((msg.reply_to,
+ Message(properties = {"type": "empty"})))
return result
def ignored(self, msg):
diff --git a/qpid/python/examples/reservations/machine-agent b/qpid/python/examples/reservations/machine-agent
index 9df663bdf5..a221a8b6de 100755
--- a/qpid/python/examples/reservations/machine-agent
+++ b/qpid/python/examples/reservations/machine-agent
@@ -20,7 +20,6 @@
import optparse, socket
from qpid.messaging import *
-from qpid.util import URL
from qpid.log import enable, DEBUG, WARN
from common import *
@@ -46,11 +45,7 @@ if opts.verbose:
else:
enable("qpid", WARN)
-url = URL(opts.broker)
-conn = Connection.open(url.host, url.port or AMQP_PORT,
- username=url.user, password=url.password,
- reconnect=True,
- reconnect_delay=1)
+conn = Connection.establish(opts.broker, reconnect=True, reconnect_interval=1)
class Agent(Dispatcher):
@@ -72,8 +67,7 @@ class Agent(Dispatcher):
def do_discover(self, msg):
r = self.get_status()
- r.to = msg.reply_to
- return [r]
+ return [(msg.reply_to, r)]
def do_reserve(self, msg):
if self.status == FREE:
diff --git a/qpid/python/examples/reservations/reserve b/qpid/python/examples/reservations/reserve
index cabc103c77..68e7fee912 100755
--- a/qpid/python/examples/reservations/reserve
+++ b/qpid/python/examples/reservations/reserve
@@ -21,7 +21,6 @@
import optparse, os, sys, time
from uuid import uuid4
from qpid.messaging import *
-from qpid.util import URL
from qpid.log import enable, DEBUG, WARN
from common import *
@@ -58,9 +57,7 @@ if args:
else:
patterns = ["*"]
-url = URL(opts.broker)
-conn = Connection.open(url.host, url.port or AMQP_PORT,
- username=url.user, password=url.password)
+conn = Connection.establish(opts.broker)
if opts.release:
request_type = "release"