https://issues.apache.org/activemq/browse/AMQ-2927 - support for configuring custom broker id

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@999924 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Bosanac Dejan 2010-09-22 13:04:59 +00:00
parent 9041c3fc78
commit 996b7a53a3
2 changed files with 15 additions and 4 deletions

View File

@ -522,7 +522,9 @@ public class BrokerService implements Service {
registerFTConnectorMBean(masterConnector);
}
}
brokerId = broker.getBrokerId();
if (brokerId == null) {
brokerId = broker.getBrokerId();
}
if (ioExceptionHandler == null) {
setIoExceptionHandler(new DefaultIOExceptionHandler());
}
@ -1820,6 +1822,9 @@ public class BrokerService implements Service {
regionBroker.setKeepDurableSubsActive(keepDurableSubsActive);
regionBroker.setBrokerName(getBrokerName());
regionBroker.getDestinationStatistics().setEnabled(enableStatistics);
if (brokerId != null) {
regionBroker.setBrokerId(brokerId);
}
return regionBroker;
}
@ -2345,6 +2350,9 @@ public class BrokerService implements Service {
public void setBrokerContext(BrokerContext brokerContext) {
this.brokerContext = brokerContext;
}
}
public void setBrokerId(String brokerId) {
this.brokerId = new BrokerId(brokerId);
}
}

View File

@ -39,8 +39,10 @@ public class AMQ2927Test extends JmsMultipleBrokersTestSupport {
public void setUp() throws Exception {
super.setAutoFail(true);
super.setUp();
createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false&deleteAllMessagesOnStartup=true"));
createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=true&useJmx=false"));
BrokerService brokerA = createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false&deleteAllMessagesOnStartup=true"));
brokerA.setBrokerId("BrokerA");
BrokerService brokerB = createBroker(new URI("broker:(tcp://localhost:61617)/BrokerB?persistent=true&useJmx=false&deleteAllMessagesOnStartup=true"));
brokerB.setBrokerId("BrokerB");
NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker, false, 2, true, true);
aTOb.addStaticallyIncludedDestination(queue);
NetworkConnector bTOa = bridgeBrokers(brokers.get("BrokerB").broker, brokers.get("BrokerA").broker, false, 2, true, true);
@ -122,6 +124,7 @@ public class AMQ2927Test extends JmsMultipleBrokersTestSupport {
protected void restartBroker(String brokerName) throws Exception {
destroyBroker("BrokerA");
BrokerService broker = createBroker(new URI("broker:(tcp://localhost:61616)/BrokerA?persistent=true&useJmx=false"));
broker.setBrokerId("BrokerA");
NetworkConnector aTOb = bridgeBrokers(brokers.get("BrokerA").broker, brokers.get("BrokerB").broker, false, 2, true, true);
aTOb.addStaticallyIncludedDestination(queue);
broker.start();