protected void unregisterMBean(ObjectName name) { if (name != null) { try { managementContext.unregisterMBean(name); } catch (Throwable e) { LOG.warn("Failed to unregister MBean {}", name); LOG.debug("Failure reason: ", e); } } }
/** * Unregisters the MBean from the MBeanServer of the management context * provided at creation time. * This method is called by the TransportLogger object being managed when * the TransportLogger object is finalized, to avoid the memory leak that * would be caused if MBeans were not unregistered. */ public void unregister() { TransportLoggerView.transportLoggerViews.remove(this); try { this.managementContext.unregisterMBean(this.name); } catch (Exception e) { log.error("Could not unregister MBean for TransportLoggerView " + id + "with name " + this.name.toString() + ", reason: " + e, e); } }
protected void unregisterProducer(ObjectName key) throws Exception { queueProducers.remove(key); topicProducers.remove(key); temporaryQueueProducers.remove(key); temporaryTopicProducers.remove(key); dynamicDestinationProducers.remove(key); if (registeredMBeans.remove(key)) { try { managementContext.unregisterMBean(key); } catch (Throwable e) { LOG.warn("Failed to unregister MBean {}", key); LOG.debug("Failure reason: ", e); } } }
public void stop() { try { if (this.transportLoggerControlCreated) { this.managementContext.unregisterMBean(this.objectName); this.managementContext.stop(); this.managementContext = null; } } catch (Exception e) { LOG.error("TransportLoggerFactory could not be stopped, reason: " + e, e); } }
public void unregister(XATransaction transaction) { try { ObjectName objectName = BrokerMBeanSupport.createXATransactionName(brokerObjectName, transaction); if (registeredMBeans.remove(objectName)) { try { managementContext.unregisterMBean(objectName); } catch (Throwable e) { LOG.warn("Failed to unregister MBean {}", objectName); LOG.debug("Failure reason: ", e); } } } catch (Exception e) { LOG.warn("Failed to create object name to unregister {}", transaction, e); } }
@Override protected void doStop(ServiceStopper stopper) { super.doStop(stopper); // lets remove any mbeans not yet removed for (Iterator<ObjectName> iter = registeredMBeans.iterator(); iter.hasNext();) { ObjectName name = iter.next(); try { managementContext.unregisterMBean(name); } catch (InstanceNotFoundException e) { LOG.warn("The MBean {} is no longer registered with JMX", name); } catch (Exception e) { stopper.onException(this, e); } } registeredMBeans.clear(); }
private void purgeInactiveDestinationView(Map<ActiveMQDestination, NetworkDestinationContainer> map) { long time = System.currentTimeMillis() - networkBridgeConfiguration.getGcSweepTime(); for (Iterator<Map.Entry<ActiveMQDestination, NetworkDestinationContainer>> it = map.entrySet().iterator(); it.hasNext(); ) { Map.Entry<ActiveMQDestination, NetworkDestinationContainer> entry = it.next(); if (entry.getValue().view.getLastAccessTime() <= time) { ObjectName objectName = entry.getValue().objectName; if (objectName != null) { try { brokerService.getManagementContext().unregisterMBean(entry.getValue().objectName); } catch (Throwable e) { LOG.debug("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } } entry.getValue().view.close(); it.remove(); } } }
public void stop() { if (!brokerService.isUseJmx()) { return; } scheduler.cancel(purgeInactiveDestinationViewTask); for (NetworkDestinationContainer networkDestinationContainer : inboundDestinationViewMap.values()) { try { brokerService.getManagementContext().unregisterMBean(networkDestinationContainer.objectName); } catch (Exception e) { LOG.error("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } } for (NetworkDestinationContainer networkDestinationContainer : outboundDestinationViewMap.values()) { try { brokerService.getManagementContext().unregisterMBean(networkDestinationContainer.objectName); } catch (Exception e) { LOG.debug("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } } inboundDestinationViewMap.clear(); outboundDestinationViewMap.clear(); }
protected void unregisterNetworkConnectorMBean(NetworkConnector connector) { if (isUseJmx()) { try { ObjectName objectName = createNetworkConnectorObjectName(connector); getManagementContext().unregisterMBean(objectName); } catch (Exception e) { LOG.warn("Network Connector could not be unregistered from JMX due " + e.getMessage() + ". This exception is ignored.", e); } } }
private void unregisterMBeans() { BrokerService broker = getBrokerService(); if (broker.isUseJmx() && this.objectName != null) { try { broker.getManagementContext().unregisterMBean(objectName); } catch (JMException e) { LOG.warn("Trying uninstall VirtualDestinationSelectorCache; couldn't uninstall mbeans, continuting..."); } } }
protected void unregisterDestination(ObjectName key) throws Exception { DestinationView view = removeAndRemember(topics, key, null); view = removeAndRemember(queues, key, view); view = removeAndRemember(temporaryQueues, key, view); view = removeAndRemember(temporaryTopics, key, view); if (registeredMBeans.remove(key)) { try { managementContext.unregisterMBean(key); } catch (Throwable e) { LOG.warn("Failed to unregister MBean {}", key); LOG.debug("Failure reason: ", e); } } if (view != null) { key = view.getSlowConsumerStrategy(); if (key!= null && registeredMBeans.remove(key)) { try { managementContext.unregisterMBean(key); } catch (Throwable e) { LOG.warn("Failed to unregister slow consumer strategy MBean {}", key); LOG.debug("Failure reason: ", e); } } } }
public void unregisterSubscription(Subscription sub) { ObjectName name = subscriptionMap.remove(sub); if (name != null) { try { SubscriptionKey subscriptionKey = new SubscriptionKey(sub.getContext().getClientId(), sub.getConsumerInfo().getSubscriptionName()); ObjectName inactiveName = subscriptionKeys.remove(subscriptionKey); if (inactiveName != null) { inactiveDurableTopicSubscribers.remove(inactiveName); managementContext.unregisterMBean(inactiveName); } } catch (Exception e) { LOG.error("Failed to unregister subscription {}", sub, e); } } }
@Override public void onStop(NetworkBridge bridge) { if (!brokerService.isUseJmx()) { return; } try { ObjectName objectName = bridge.getMbeanObjectName(); if (objectName != null) { brokerService.getManagementContext().unregisterMBean(objectName); } MBeanBridgeDestination mBeanBridgeDestination = destinationObjectNameMap.remove(bridge); if (mBeanBridgeDestination != null){ mBeanBridgeDestination.stop(); } } catch (Throwable e) { LOG.debug("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } }
protected void unregisterConnectorMBean(TransportConnector connector) throws IOException { if (isUseJmx()) { try { ObjectName objectName = createConnectorObjectName(connector); getManagementContext().unregisterMBean(objectName); } catch (Throwable e) { throw IOExceptionSupport.create( "Transport Connector could not be unregistered in JMX: " + e.getMessage(), e); } } }
protected void unregisterNetworkBridgeMBean(NetworkBridge bridge) { if (!getBrokerService().isUseJmx()) { return; } try { ObjectName objectName = createNetworkBridgeObjectName(bridge); getBrokerService().getManagementContext().unregisterMBean(objectName); } catch (Throwable e) { LOG.debug("Network bridge could not be unregistered in JMX: {}", e.getMessage(), e); } }
inactiveDurableTopicSubscribers.remove(inactiveName); registeredMBeans.remove(inactiveName); managementContext.unregisterMBean(inactiveName);
/** * @throws Exception * @see org.apache.activemq.Service#stop() */ @Override public void doStop(ServiceStopper stopper) throws Exception { this.letter.stop(); if (brokerService != null && brokerService.isUseJmx()) { ObjectName brokerObjectName = brokerService.getBrokerObjectName(); brokerService.getManagementContext().unregisterMBean(createPersistenceAdapterName(brokerObjectName.toString(), toString())); } }
protected void unregisterSubscription(ObjectName key, boolean addToInactive) throws Exception { queueSubscribers.remove(key); topicSubscribers.remove(key); temporaryQueueSubscribers.remove(key); temporaryTopicSubscribers.remove(key); if (registeredMBeans.remove(key)) { try { managementContext.unregisterMBean(key); } catch (Throwable e) { LOG.warn("Failed to unregister MBean {}", key); LOG.debug("Failure reason: ", e); } } DurableSubscriptionView view = (DurableSubscriptionView)durableTopicSubscribers.remove(key); if (view != null) { // need to put this back in the inactive list SubscriptionKey subscriptionKey = new SubscriptionKey(view.getClientId(), view.getSubscriptionName()); if (addToInactive) { SubscriptionInfo info = new SubscriptionInfo(); info.setClientId(subscriptionKey.getClientId()); info.setSubscriptionName(subscriptionKey.getSubscriptionName()); info.setDestination(new ActiveMQTopic(view.getDestinationName())); info.setSelector(view.getSelector()); addInactiveSubscription(subscriptionKey, info, (brokerService.isKeepDurableSubsActive() ? view.subscription : null)); } } }
protected void unregisterNetworkConnectorMBean(NetworkConnector connector) { if (isUseJmx()) { try { ObjectName objectName = createNetworkConnectorObjectName(connector); getManagementContext().unregisterMBean(objectName); } catch (Exception e) { LOG.warn("Network Connector could not be unregistered from JMX due " + e.getMessage() + ". This exception is ignored.", e); } } }
protected void unregisterConnectorMBean(TransportConnector connector) throws IOException { if (isUseJmx()) { try { ObjectName objectName = createConnectorObjectName(connector); getManagementContext().unregisterMBean(objectName); } catch (Throwable e) { throw IOExceptionSupport.create( "Transport Connector could not be unregistered in JMX: " + e.getMessage(), e); } } }