From 0051c4ea6f579cab730d89364d0a53b043a90995 Mon Sep 17 00:00:00 2001 From: Gary Tully Date: Tue, 24 Jul 2012 10:49:47 +0000 Subject: [PATCH] https://issues.apache.org/jira/browse/AMQ-3696 - fix regression in FailoverStaticNetworkTest, in jvm slave overwriting broker registry entry of master git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1364973 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/activemq/broker/BrokerService.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java index dc4010f130..d481ee0c24 100644 --- a/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java +++ b/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java @@ -520,9 +520,14 @@ public class BrokerService implements Service { if (isUseJmx()) { startManagementContext(); } - BrokerRegistry.getInstance().bind(getBrokerName(), BrokerService.this); + // in jvm master slave, lets not publish over existing broker till we get the lock + final BrokerRegistry brokerRegistry = BrokerRegistry.getInstance(); + if (brokerRegistry.lookup(getBrokerName()) == null) { + brokerRegistry.bind(getBrokerName(), BrokerService.this); + } startPersistenceAdapter(startAsync); startBroker(startAsync); + brokerRegistry.bind(getBrokerName(), BrokerService.this); } catch (Exception e) { LOG.error("Failed to start ActiveMQ JMS Message Broker (" + getBrokerName() + ", " + brokerId + "). Reason: " + e, e); try {