HornetQServer server = createServer(false, isNetty);
server.start();
ClientSessionInternal session = null;
try
{
ClientSessionFactory factory = createFactory(isNetty);
factory.setClientFailureCheckPeriod(pingPeriod); // Using a smaller timeout
factory.setRetryInterval(500);
factory.setRetryIntervalMultiplier(1d);
factory.setReconnectAttempts(-1);
factory.setConfirmationWindowSize(1024 * 1024);
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)
{
count.incrementAndGet();
latch.countDown();
}
public void beforeReconnect(final HornetQException exception)
{
}
});
server.stop();
Thread.sleep((pingPeriod * 2));
server.start();
Assert.assertTrue(latch.await(5, TimeUnit.SECONDS));
// Some time to let possible loops to occur
Thread.sleep(500);
Assert.assertEquals(1, count.get());
}
finally
{
try
{
session.close();
}
catch (Throwable e)
{
}