You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by tr...@apache.org on 2008/11/24 20:51:03 UTC
svn commit: r720276 -
/incubator/qpid/trunk/qpid/python/commands/qpid-printevents
Author: tross
Date: Mon Nov 24 11:51:03 2008
New Revision: 720276
URL: http://svn.apache.org/viewvc?rev=720276&view=rev
Log:
QPID-1484 - qpid-printevents now handles connection loss/reconnect
Modified:
incubator/qpid/trunk/qpid/python/commands/qpid-printevents
Modified: incubator/qpid/trunk/qpid/python/commands/qpid-printevents
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/python/commands/qpid-printevents?rev=720276&r1=720275&r2=720276&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/python/commands/qpid-printevents (original)
+++ incubator/qpid/trunk/qpid/python/commands/qpid-printevents Mon Nov 24 11:51:03 2008
@@ -23,13 +23,20 @@
import optparse
import sys
import socket
-import time
+from time import time, strftime, gmtime, sleep
from qmf.console import Console, Session
class EventConsole(Console):
def event(self, broker, event):
print event
+ def brokerConnected(self, broker):
+ print strftime("%c", gmtime(time())), "NOTIC qpid-printevents:brokerConnected broker=%s" % broker.getUrl()
+
+ def brokerDisconnected(self, broker):
+ print strftime("%c", gmtime(time())), "NOTIC qpid-printevents:brokerDisconnected broker=%s" % broker.getUrl()
+
+
##
## Main Program
##
@@ -48,14 +55,17 @@
arguments.append("localhost")
console = EventConsole()
- session = Session(console, rcvObjects=False, rcvHeartbeats=False)
+ session = Session(console, rcvObjects=False, rcvHeartbeats=False, manageConnections=True)
+ brokers = []
for host in arguments:
- session.addBroker(host)
+ brokers.append(session.addBroker(host))
try:
while (True):
- time.sleep(10)
+ sleep(10)
except KeyboardInterrupt:
+ for broker in brokers:
+ session.delBroker(broker)
print
sys.exit(0)