subscribed = false;
log.error("Error while subscribing to the topic: " + topicName, e);
} finally {
if(subscribed) {
// start the health checker if subscribed
healthChecker = new TopicHealthChecker(topicName);
Thread healthCheckerThread = new Thread(healthChecker);
healthCheckerThread.start();
try {
// waits till the thread finishes.
healthCheckerThread.join();