diff --git a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java index bf9332540a..54af39b280 100755 --- a/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java +++ b/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgent.java @@ -471,7 +471,7 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable { } private void fireServiceRemovedEvent(RemoteBrokerData data) { - if (discoveryListener != null) { + if (discoveryListener != null && started.get()) { final DiscoveryEvent event = new DiscoveryEvent(data.service); event.setBrokerName(data.brokerName); @@ -490,7 +490,7 @@ public class MulticastDiscoveryAgent implements DiscoveryAgent, Runnable { } private void fireServiceAddEvent(RemoteBrokerData data) { - if (discoveryListener != null) { + if (discoveryListener != null && started.get()) { final DiscoveryEvent event = new DiscoveryEvent(data.service); event.setBrokerName(data.brokerName);