final String xmlConfig = getClass().getPackage().getName().replace('.','/') + "/loadbalancetest.xml";
System.setProperty("lbt.networkBridgePrefetch", String.valueOf(networkBridgePrefetch));
System.setProperty("lbt.brokerName", "one");
final ActiveMQConnectionFactory connectionFactory1 = new ActiveMQConnectionFactory(
"vm://one?brokerConfig=xbean:" + xmlConfig);
final SingleConnectionFactory singleConnectionFactory1 = new SingleConnectionFactory(
connectionFactory1);
singleConnectionFactory1.setReconnectOnException(true);
final DefaultMessageListenerContainer container1 = new DefaultMessageListenerContainer();
container1.setConnectionFactory(singleConnectionFactory1);
container1.setMaxConcurrentConsumers(1);
container1.setDestination(new ActiveMQQueue(TESTING_QUEUE));
container1.setMessageListener(new MessageListener() {
public void onMessage(final Message message) {
broker1Count.incrementAndGet();
}
});
container1.afterPropertiesSet();
container1.start();
pool.submit(new Callable<Object>() {
public Object call() throws Exception {
System.setProperty("lbt.brokerName", "two");
final ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory(
"vm://two?brokerConfig=xbean:" + xmlConfig);
final SingleConnectionFactory singleConnectionFactory2 = new SingleConnectionFactory(
connectionFactory2);
singleConnectionFactory2.setReconnectOnException(true);
final DefaultMessageListenerContainer container2 = new DefaultMessageListenerContainer();
container2.setConnectionFactory(singleConnectionFactory2);
container2.setMaxConcurrentConsumers(1);
container2.setDestination(new ActiveMQQueue(TESTING_QUEUE));
container2.setMessageListener(new MessageListener() {