diff options
author | Rafael H. Schloming <rhs@apache.org> | 2010-01-29 21:41:46 +0000 |
---|---|---|
committer | Rafael H. Schloming <rhs@apache.org> | 2010-01-29 21:41:46 +0000 |
commit | 7f2532ceb27fae57ebe8f2d80ba40665f0e6e1cf (patch) | |
tree | 4f50d2aa59d1d134c6014a1904a086a8fe1ed4ec /python/examples/api/drain | |
parent | 576ca5afb5d8016bbaad44db260124be029ce145 (diff) | |
download | qpid-python-7f2532ceb27fae57ebe8f2d80ba40665f0e6e1cf.tar.gz |
added reconnect_delay, reconnect_limit, and backups option to Connection
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@904634 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'python/examples/api/drain')
-rwxr-xr-x | python/examples/api/drain | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/python/examples/api/drain b/python/examples/api/drain index 485985f16d..ef1f050c8c 100755 --- a/python/examples/api/drain +++ b/python/examples/api/drain @@ -21,18 +21,32 @@ import optparse from qpid.messaging import * from qpid.util import URL +from qpid.log import enable, DEBUG, WARN parser = optparse.OptionParser(usage="usage: %prog [options] ADDRESS ...", description="Drain messages from the supplied address.") parser.add_option("-b", "--broker", default="localhost", help="connect to specified BROKER (default %default)") +parser.add_option("-r", "--reconnect", action="store_true", + help="enable auto reconnect") +parser.add_option("-d", "--reconnect-delay", type=float, default=3, + help="delay between reconnect attempts") +parser.add_option("-l", "--reconnect-limit", type=int, + help="maximum number of reconnect attempts") parser.add_option("-t", "--timeout", type=float, default=0, help="timeout in seconds to wait before exiting (default %default)") parser.add_option("-f", "--forever", action="store_true", help="ignore timeout and wait forever") +parser.add_option("-v", dest="verbose", action="store_true", + help="enable logging") opts, args = parser.parse_args() +if opts.verbose: + enable("qpid", DEBUG) +else: + enable("qpid", WARN) + url = URL(opts.broker) if args: addr = args.pop(0) @@ -45,7 +59,11 @@ else: # XXX: should make URL default the port for us conn = Connection.open(url.host, url.port or AMQP_PORT, - username=url.user, password=url.password) + username=url.user, + password=url.password, + reconnect=opts.reconnect, + reconnect_delay=opts.reconnect_delay, + reconnect_limit=opts.reconnect_limit) ssn = conn.session() rcv = ssn.receiver(addr) |