leaderElection = new LeaderElection(zkClient, "/tx.service/leader", new ElectionHandler() {
@Override
public void leader() {
// if the txManager fails, we should stop the server
txManager = txManagerProvider.get();
txManager.addListener(new ServiceListenerAdapter() {
@Override
public void failed(State from, Throwable failure) {
LOG.error("Transaction manager aborted, stopping transaction service");
stopAndWait();
}