summaryrefslogtreecommitdiff
path: root/cpp/bindings/qmf2/examples/python/agent.py
diff options
context:
space:
mode:
authorTed Ross <tross@apache.org>2010-11-10 22:30:38 +0000
committerTed Ross <tross@apache.org>2010-11-10 22:30:38 +0000
commit72897efdcb587221bd8bec5af6ffa57092e8cab7 (patch)
tree19b619d7ca5852f5d5f6dc228ca043dc75bf4edf /cpp/bindings/qmf2/examples/python/agent.py
parent332081014d8a62c8f75c36b9d53af01e29b1f9af (diff)
downloadqpid-python-72897efdcb587221bd8bec5af6ffa57092e8cab7.tar.gz
Fixed segfault when setting the agent filter on a closed session.
Fixed notification for the connected-broker agent. Added an example console program in c++ to monitor the set of agents. Fixed the Python agent example to more elegantly handle connection failure. git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1033763 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/bindings/qmf2/examples/python/agent.py')
-rwxr-xr-xcpp/bindings/qmf2/examples/python/agent.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/cpp/bindings/qmf2/examples/python/agent.py b/cpp/bindings/qmf2/examples/python/agent.py
index a915ed59b1..d354106042 100755
--- a/cpp/bindings/qmf2/examples/python/agent.py
+++ b/cpp/bindings/qmf2/examples/python/agent.py
@@ -35,12 +35,14 @@ class ExampleAgent(AgentHandler):
## Create and open a messaging connection to a broker.
##
self.connection = cqpid.Connection(url)
+ self.session = None
self.connection.open()
##
## Create, configure, and open a QMFv2 agent session using the connection.
##
self.session = AgentSession(self.connection, "{interval:30}")
+ self.session.setDomain("test")
self.session.setVendor('profitron.com')
self.session.setProduct('blastinator')
self.session.setAttribute('attr1', 1000)
@@ -56,7 +58,8 @@ class ExampleAgent(AgentHandler):
"""
Clean up the session and connection.
"""
- self.session.close()
+ if self.session:
+ self.session.close()
self.connection.close()
@@ -141,10 +144,13 @@ class ExampleAgent(AgentHandler):
self.controlAddr = self.session.addData(self.control, "singleton")
+try:
+ agent = ExampleAgent("localhost")
+ agent.setupSchema()
+ agent.populateData()
+ agent.run() # Use agent.start() to launch the agent in a separate thread
+ agent.shutdown()
+except Exception, e:
+ print "Exception Caught:", e
-agent = ExampleAgent("localhost")
-agent.setupSchema()
-agent.populateData()
-agent.run() # Use agent.start() to launch the agent in a separate thread
-agent.shutdown()