wait for network bridge formation before starting producer to ensure load is distributed

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1080191 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Gary Tully 2011-03-10 11:39:59 +00:00
parent f93d05acef
commit b6672d12b2
1 changed files with 8 additions and 0 deletions

View File

@ -59,6 +59,7 @@ public class LoadBalanceTest {
final int total = 100;
final AtomicInteger broker1Count = new AtomicInteger(0);
final AtomicInteger broker2Count = new AtomicInteger(0);
final CountDownLatch startProducer = new CountDownLatch(1);
try {
{
brokerService1 = new BrokerService();
@ -137,6 +138,9 @@ public class LoadBalanceTest {
});
container2.afterPropertiesSet();
container2.start();
assertTrue("wait for start signal", startProducer.await(20, TimeUnit.SECONDS));
final CachingConnectionFactory cachingConnectionFactory = new CachingConnectionFactory(
singleConnectionFactory2);
final JmsTemplate template = new JmsTemplate(
@ -173,6 +177,10 @@ public class LoadBalanceTest {
}
});
pool.shutdown();
waitForBridgeFormation(10000);
startProducer.countDown();
pool.awaitTermination(10, TimeUnit.SECONDS);
LOG.info("broker1Count " + broker1Count.get() + ", broker2Count " + broker2Count.get());