// One for beforeReconnecto from the Factory, and one for the commit about to be done
final CountDownLatch latchCommit = new CountDownLatch(2);
final ArrayList<Thread> threadToBeInterrupted = new ArrayList<Thread>();
factory.addFailureListener(new SessionFailureListener()
{
@Override
public void connectionFailed(HornetQException exception, boolean failedOver)
{
}
@Override
public void beforeReconnect(HornetQException exception)
{
latchCommit.countDown();
threadToBeInterrupted.add(Thread.currentThread());
System.out.println("Thread " + Thread.currentThread() + " reconnecting now");
}
});
final ClientSessionInternal session = (ClientSessionInternal)factory.createSession();
final AtomicInteger count = new AtomicInteger(0);
final CountDownLatch latch = new CountDownLatch(1);
session.addFailureListener(new SessionFailureListener()
{
public void connectionFailed(final HornetQException me, boolean failedOver)
{
count.incrementAndGet();