Don't exit the broker stop loop if you get an exception, log it and stop the rest if possible.

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1371200 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Timothy A. Bish 2012-08-09 13:24:33 +00:00
parent d45dedbd23
commit e28b55c142
1 changed files with 36 additions and 33 deletions

View File

@ -16,7 +16,21 @@
*/ */
package org.apache.activemq.transport.failover; package org.apache.activemq.transport.failover;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.activemq.broker.BrokerService; import org.apache.activemq.broker.BrokerService;
@ -25,18 +39,6 @@ import org.apache.activemq.network.NetworkConnector;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Queue;
import javax.jms.Session;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
public class FailoverClusterTestSupport extends TestCase { public class FailoverClusterTestSupport extends TestCase {
protected final Logger logger = LoggerFactory.getLogger(getClass()); protected final Logger logger = LoggerFactory.getLogger(getClass());
@ -122,8 +124,13 @@ public class FailoverClusterTestSupport extends TestCase {
protected void destroyBrokerCluster() throws JMSException, Exception { protected void destroyBrokerCluster() throws JMSException, Exception {
for (BrokerService b : brokers.values()) { for (BrokerService b : brokers.values()) {
try {
b.stop(); b.stop();
b.waitUntilStopped(); b.waitUntilStopped();
} catch (Exception e) {
// Keep on going, we want to try and stop them all.
logger.info("Error while stopping broker["+ b.getBrokerName() +"] continuing...");
}
} }
brokers.clear(); brokers.clear();
} }
@ -144,8 +151,7 @@ public class FailoverClusterTestSupport extends TestCase {
} }
protected void addTransportConnector(BrokerService brokerService, protected void addTransportConnector(BrokerService brokerService,
String connectorName, String uri, boolean clustered) String connectorName, String uri, boolean clustered) throws Exception {
throws Exception {
TransportConnector connector = brokerService.addConnector(uri); TransportConnector connector = brokerService.addConnector(uri);
connector.setName(connectorName); connector.setName(connectorName);
if (clustered) { if (clustered) {
@ -160,8 +166,7 @@ public class FailoverClusterTestSupport extends TestCase {
} }
protected void addNetworkBridge(BrokerService answer, String bridgeName, protected void addNetworkBridge(BrokerService answer, String bridgeName,
String uri, boolean duplex, String destinationFilter) String uri, boolean duplex, String destinationFilter) throws Exception {
throws Exception {
NetworkConnector network = answer.addNetworkConnector(uri); NetworkConnector network = answer.addNetworkConnector(uri);
network.setName(bridgeName); network.setName(bridgeName);
network.setDuplex(duplex); network.setDuplex(duplex);
@ -176,11 +181,9 @@ public class FailoverClusterTestSupport extends TestCase {
@SuppressWarnings("unused") @SuppressWarnings("unused")
protected void createClients(int numOfClients) throws Exception { protected void createClients(int numOfClients) throws Exception {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory( ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(clientUrl);
clientUrl);
for (int i = 0; i < numOfClients; i++) { for (int i = 0; i < numOfClients; i++) {
ActiveMQConnection c = (ActiveMQConnection) factory ActiveMQConnection c = (ActiveMQConnection) factory.createConnection();
.createConnection();
c.start(); c.start();
Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE); Session s = c.createSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = s.createQueue(getClass().getName()); Queue queue = s.createQueue(getClass().getName());