PooledConnectionFactory pcf2 = null;
ActiveMQConnectionFactory acf3 = null;
ActiveMQConnectionFactory acf4 = null;
PooledConnectionFactory pcf3 = null;
PooledConnectionFactory pcf4 = null;
DefaultMessageListenerContainer container1 = null;
try {
// Test with and without queue limits.
brokerService1 = createBrokerService("broker1", BROKER_URL1, BROKER_URL2, BROKER_URL3, BROKER_URL4, 0 /* 10000000 */);
brokerService1.start();
brokerService2 = createBrokerService("broker2", BROKER_URL2, BROKER_URL1, BROKER_URL3, BROKER_URL4, 0/* 40000000 */);
brokerService2.start();
brokerService3 = createBrokerService("broker3", BROKER_URL3, BROKER_URL2, BROKER_URL1, BROKER_URL4, 0/* 10000000 */);
brokerService3.start();
brokerService4 = createBrokerService("broker4", BROKER_URL4, BROKER_URL1, BROKER_URL3, BROKER_URL2, 0/* 10000000 */);
brokerService4.start();
final String failover1 = "failover:(" + URL1
+ ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";
final String failover2 = "failover:(" + URL2
+ ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";
final String failover3 = "failover:(" + URL3
+ ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";
final String failover4 = "failover:(" + URL4
+ ")?initialReconnectDelay=10&maxReconnectDelay=30000&useExponentialBackOff=true&backOffMultiplier=2&maxReconnectAttempts=0&randomize=false";
acf1 = createConnectionFactory(failover1);
acf2 = createConnectionFactory(failover2);
acf3 = createConnectionFactory(failover3);
acf4 = createConnectionFactory(failover4);
pcf1 = new PooledConnectionFactory(acf1);
pcf2 = new PooledConnectionFactory(acf2);
pcf3 = new PooledConnectionFactory(acf3);
pcf4 = new PooledConnectionFactory(acf4);
container1 = createDefaultMessageListenerContainer(acf2, new TestMessageListener1(0), QUEUE1_NAME);
container1.afterPropertiesSet();
final PooledProducerTask[] task = new PooledProducerTask[4];
task[0] = new PooledProducerTask(pcf1, QUEUE1_NAME, "producer1");
task[1] = new PooledProducerTask(pcf2, QUEUE1_NAME, "producer2");
task[2] = new PooledProducerTask(pcf3, QUEUE1_NAME, "producer3");
task[3] = new PooledProducerTask(pcf4, QUEUE1_NAME, "producer4");
final ExecutorService executor = Executors.newCachedThreadPool();
for (int i = 0; i < 4; i++) {
executor.submit(task[i]);
}
LATCH.await(15, TimeUnit.SECONDS);
assertTrue(LATCH.getCount() == MAX_CONSUMERS * NUM_MESSAGE_TO_SEND);
} catch (Exception e) {
e.printStackTrace();
} finally {
container1.stop();
container1.destroy();
container1 = null;
brokerService1.stop();
brokerService1 = null;
brokerService2.stop();