locator.setConfirmationWindowSize(1024 * 1024);
final ClientSessionFactoryInternal sf = (ClientSessionFactoryInternal)locator.createSessionFactory();
session = sf.createSession();
final RemotingConnection connFailure = ((ClientSessionInternal)session).getConnection();
int numberOfThreads = 100;
final int numberOfSessionsToCreate = 10;
final CountDownLatch alignLatch = new CountDownLatch(numberOfThreads);
final CountDownLatch startFlag = new CountDownLatch(1);
class CreateSessionThread extends Thread
{
Throwable failure;
@Override
public void run()
{
try
{
alignLatch.countDown();
startFlag.await();
for (int i = 0; i < numberOfSessionsToCreate; i++)
{
Thread.yield();
ClientSession session = sf.createSession(false, true, true);
session.close();
}
}
catch (Throwable e)
{
e.printStackTrace();
failure = e;
}
}
}
CreateSessionThread threads[] = new CreateSessionThread[numberOfThreads];
for (int i = 0; i < numberOfThreads; i++)
{
threads[i] = new CreateSessionThread();
threads[i].start();
}
alignLatch.await();
timer.schedule(new TimerTask()
{
@Override
public void run()
{
try
{
connFailure.fail(new HornetQException(HornetQException.NOT_CONNECTED));
}
catch (Exception e)
{
ReattachTest.log.warn("Error on the timer " + e);
}