@Override
public void run() {
if(log.isDebugEnabled()){
log.debug(topicName + " topic health checker is running... " );
}
TopicConnector testConnector = new TopicConnector();
while (!terminated) {
try {
// Health checker needs to run with the smallest possible time interval
// to detect a connection drop. Otherwise the subscriber will not
// get reconnected after a connection drop.
Thread.sleep(1000);
testConnector.init(topicName);
// A ping event is published to detect a session timeout
EventPublisherPool.getPublisher(Constants.PING_TOPIC).publish(new PingEvent(), false);
} catch (Exception e) {
// Implies connection is not established
// sleep for 30 sec and retry
try {
log.error(topicName + " topic health checker is failed and will try to subscribe again in 30 sec");
Thread.sleep(30000);
break;
} catch (InterruptedException ignore) {
}
} finally {
try {
testConnector.close();
} catch (JMSException ignore) {
}
}
}