Author: rajdavies
Date: Wed Apr 9 02:45:22 2008
New Revision: 646245
URL: http://svn.apache.org/viewvc?rev=646245&view=rev
Log:
Applied patch for https://issues.apache.org/activemq/browse/AMQ-1511
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=646245&r1=646244&r2=646245&view=diff
==============================================================================
---
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Wed Apr 9 02:45:22 2008
@@ -439,12 +439,17 @@
getBroker().start();
- /*
- * if(isUseJmx()){ // yes - this is order dependent! // register
all
- * destination in persistence store including inactive destinations
- * as mbeans this.startDestinationsInPersistenceStore(broker); }
- */
- startAllConnectors();
+ // see if there is a MasterBroker service and if so, configure
+ // it and start it.
+ for (Service service : services) {
+ if (service instanceof MasterConnector) {
+ configureService(service);
+ service.start();
+ }
+ }
+ if (!isSlave()) {
+ startAllConnectors();
+ }
if (isUseJmx() && masterConnector != null) {
registerFTConnectorMBean(masterConnector);
@@ -1301,6 +1306,7 @@
* @throws Exception
*/
protected void processHelperProperties() throws Exception {
+ boolean masterServiceExists = false;
if (transportConnectorURIs != null) {
for (int i = 0; i < transportConnectorURIs.length; i++) {
String uri = transportConnectorURIs[i];
@@ -1319,8 +1325,14 @@
addJmsConnector(jmsBridgeConnectors[i]);
}
}
+ for (Service service : services) {
+ if (service instanceof MasterConnector) {
+ masterServiceExists = true;
+ break;
+ }
+ }
if (masterConnectorURI != null) {
- if (masterConnector != null) {
+ if (masterServiceExists) {
throw new IllegalStateException("Cannot specify
masterConnectorURI when a masterConnector is already registered via the
services property");
} else {
addService(new MasterConnector(masterConnectorURI));
@@ -1843,12 +1855,14 @@
*/
protected void configureService(Object service) {
if (service instanceof BrokerServiceAware) {
- BrokerServiceAware serviceAware = (BrokerServiceAware)service;
+ BrokerServiceAware serviceAware = (BrokerServiceAware) service;
serviceAware.setBrokerService(this);
}
- if (service instanceof MasterConnector) {
- masterConnector = (MasterConnector)service;
- supportFailOver = true;
+ if (masterConnector == null) {
+ if (service instanceof MasterConnector) {
+ masterConnector = (MasterConnector) service;
+ supportFailOver = true;
+ }
}
}
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
URL:
http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java?rev=646245&r1=646244&r2=646245&view=diff
==============================================================================
---
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
(original)
+++
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/ft/MasterConnector.java
Wed Apr 9 02:45:22 2008
@@ -104,7 +104,7 @@
}
localBroker = TransportFactory.connect(localURI);
remoteBroker = TransportFactory.connect(remoteURI);
- LOG.info("Starting a network connection between " + localBroker + "
and " + remoteBroker + " has been established.");
+ LOG.info("Starting a slave connection between " + localBroker + " and
" + remoteBroker + " has been established.");
localBroker.setTransportListener(new DefaultTransportListener() {
public void onCommand(Object command) {
@@ -131,21 +131,15 @@
}
}
});
- masterActive.set(true);
- Thread thead = new Thread() {
-
- public void run() {
- try {
- localBroker.start();
- remoteBroker.start();
- startBridge();
- } catch (Exception e) {
- masterActive.set(false);
- LOG.error("Failed to start network bridge: " + e, e);
- }
- }
- };
- thead.start();
+ try {
+ localBroker.start();
+ remoteBroker.start();
+ startBridge();
+ masterActive.set(true);
+ } catch (Exception e) {
+ masterActive.set(false);
+ LOG.error("Failed to start network bridge: " + e, e);
+ }
}
protected void startBridge() throws Exception {