prevent ObjectNames being unregistered from the MBeanServer if already removed in doStop()

git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@390998 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Robert Davies 2006-04-03 10:43:55 +00:00
parent a748040d31
commit 05d271a719
1 changed files with 9 additions and 12 deletions

View File

@ -22,7 +22,6 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
import javax.management.InstanceNotFoundException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
@ -34,7 +33,6 @@ import javax.management.openmbean.OpenDataException;
import javax.management.openmbean.TabularData;
import javax.management.openmbean.TabularDataSupport;
import javax.management.openmbean.TabularType;
import org.apache.activemq.broker.Broker;
import org.apache.activemq.broker.BrokerService;
import org.apache.activemq.broker.ConnectionContext;
@ -62,10 +60,8 @@ import org.apache.activemq.util.ServiceStopper;
import org.apache.activemq.util.SubscriptionKey;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
import edu.emory.mathcs.backport.java.util.concurrent.CopyOnWriteArraySet;
public class ManagedRegionBroker extends RegionBroker{
private static final Log log=LogFactory.getLog(ManagedRegionBroker.class);
private final MBeanServer mbeanServer;
@ -167,7 +163,6 @@ public class ManagedRegionBroker extends RegionBroker{
}else{
name=sub.getConsumerInfo().getConsumerId().toString();
}
try{
ObjectName objectName=new ObjectName(brokerObjectName.getDomain()+":"+"BrokerName="+map.get("BrokerName")
+","+"Type=Subscription,"+"active=true,"+"name="+JMXSupport.encodeObjectNamePart(name)+"");
@ -224,9 +219,10 @@ public class ManagedRegionBroker extends RegionBroker{
queues.remove(key);
temporaryQueues.remove(key);
temporaryTopics.remove(key);
registeredMBeans.remove(key);
if(registeredMBeans.remove(key)){
mbeanServer.unregisterMBean(key);
}
}
protected void registerSubscription(ObjectName key,ConsumerInfo info,SubscriptionKey subscriptionKey,
SubscriptionView view) throws Exception{
@ -269,8 +265,9 @@ public class ManagedRegionBroker extends RegionBroker{
inactiveDurableTopicSubscribers.remove(key);
temporaryQueueSubscribers.remove(key);
temporaryTopicSubscribers.remove(key);
registeredMBeans.remove(key);
if(registeredMBeans.remove(key)){
mbeanServer.unregisterMBean(key);
}
DurableSubscriptionView view=(DurableSubscriptionView) durableTopicSubscribers.remove(key);
if(view!=null){
// need to put this back in the inactive list