int i = 0;
int numberOfThreads = 1;
CountDownLatch latch = new CountDownLatch(numberOfThreads);
ExceptionHolder exceptionHolder = new ExceptionHolder();
try
{
for (int x = 0; x < numberOfThreads; x++)
{
Thread thread = new Thread(new ClientReceiver(latch, numRequests / numberOfThreads, exceptionHolder));
thread.start();
}
for (i = 0; i < numRequests; i++)
{
if (i == getWarmUpMessages())
{
stopWatch.start();
}
client.dispatch("CustomerRequests", requests[i % 3], null);
}
}
finally
{
latch.await();
stopWatch.stop();
System.out.println("Total running time was: " + stopWatch.getTime() + "ms");
System.out.println("Requests processed was: " + i);
int mps = (int) (numRequests / ((double) stopWatch.getTime() / (double) 1000));
System.out.println("Msg/sec: " + mps + " (warm up msgs = " + getWarmUpMessages() + ")");
if(exceptionHolder.isExceptionThrown())
{
exceptionHolder.print();
fail("Exceptions thrown during async processing");
}
}
}