mirror of https://github.com/apache/activemq.git
added a helper method to make it easier to work with the admin view together with fixed some NPEs I was getting when redeploying ActiveMQ when using mvn jetty6:run
git-svn-id: https://svn.apache.org/repos/asf/incubator/activemq/trunk@396892 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
73f0e97531
commit
8ad6fd36a1
|
@ -35,7 +35,6 @@ import org.apache.activemq.Service;
|
||||||
import org.apache.activemq.advisory.AdvisoryBroker;
|
import org.apache.activemq.advisory.AdvisoryBroker;
|
||||||
import org.apache.activemq.broker.ft.MasterConnector;
|
import org.apache.activemq.broker.ft.MasterConnector;
|
||||||
import org.apache.activemq.broker.jmx.BrokerView;
|
import org.apache.activemq.broker.jmx.BrokerView;
|
||||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
|
||||||
import org.apache.activemq.broker.jmx.ConnectorView;
|
import org.apache.activemq.broker.jmx.ConnectorView;
|
||||||
import org.apache.activemq.broker.jmx.ConnectorViewMBean;
|
import org.apache.activemq.broker.jmx.ConnectorViewMBean;
|
||||||
import org.apache.activemq.broker.jmx.FTConnectorView;
|
import org.apache.activemq.broker.jmx.FTConnectorView;
|
||||||
|
@ -96,6 +95,7 @@ public class BrokerService implements Service, Serializable {
|
||||||
private String brokerName = "localhost";
|
private String brokerName = "localhost";
|
||||||
private File dataDirectory;
|
private File dataDirectory;
|
||||||
private Broker broker;
|
private Broker broker;
|
||||||
|
private BrokerView adminView;
|
||||||
private ManagementContext managementContext;
|
private ManagementContext managementContext;
|
||||||
private ObjectName brokerObjectName;
|
private ObjectName brokerObjectName;
|
||||||
private TaskRunnerFactory taskRunnerFactory;
|
private TaskRunnerFactory taskRunnerFactory;
|
||||||
|
@ -121,7 +121,6 @@ public class BrokerService implements Service, Serializable {
|
||||||
private AtomicBoolean started = new AtomicBoolean(false);
|
private AtomicBoolean started = new AtomicBoolean(false);
|
||||||
private BrokerPlugin[] plugins;
|
private BrokerPlugin[] plugins;
|
||||||
private boolean keepDurableSubsActive=true;
|
private boolean keepDurableSubsActive=true;
|
||||||
|
|
||||||
private BrokerId brokerId;
|
private BrokerId brokerId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -426,13 +425,15 @@ public class BrokerService implements Service, Serializable {
|
||||||
|
|
||||||
if (isUseJmx()) {
|
if (isUseJmx()) {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
for (Iterator iter = registeredMBeanNames.iterator(); iter.hasNext();) {
|
if (mbeanServer != null) {
|
||||||
ObjectName name = (ObjectName) iter.next();
|
for (Iterator iter = registeredMBeanNames.iterator(); iter.hasNext();) {
|
||||||
try {
|
ObjectName name = (ObjectName) iter.next();
|
||||||
mbeanServer.unregisterMBean(name);
|
try {
|
||||||
}
|
mbeanServer.unregisterMBean(name);
|
||||||
catch (Exception e) {
|
}
|
||||||
stopper.onException(mbeanServer, e);
|
catch (Exception e) {
|
||||||
|
stopper.onException(mbeanServer, e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stopper.stop(getManagementContext());
|
stopper.stop(getManagementContext());
|
||||||
|
@ -445,6 +446,10 @@ public class BrokerService implements Service, Serializable {
|
||||||
|
|
||||||
// Properties
|
// Properties
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the message broker
|
||||||
|
*/
|
||||||
public Broker getBroker() throws Exception {
|
public Broker getBroker() throws Exception {
|
||||||
if (broker == null) {
|
if (broker == null) {
|
||||||
log.info("ActiveMQ " + ActiveMQConnectionMetaData.PROVIDER_VERSION + " JMS Message Broker ("
|
log.info("ActiveMQ " + ActiveMQConnectionMetaData.PROVIDER_VERSION + " JMS Message Broker ("
|
||||||
|
@ -455,6 +460,24 @@ public class BrokerService implements Service, Serializable {
|
||||||
return broker;
|
return broker;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the administration view of the broker; used to create and destroy resources such as queues and topics.
|
||||||
|
*
|
||||||
|
* Note this method returns null if JMX is disabled.
|
||||||
|
*/
|
||||||
|
public BrokerView getAdminView() throws Exception {
|
||||||
|
if (adminView == null) {
|
||||||
|
// force lazy creation
|
||||||
|
getBroker();
|
||||||
|
}
|
||||||
|
return adminView;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdminView(BrokerView adminView) {
|
||||||
|
this.adminView = adminView;
|
||||||
|
}
|
||||||
|
|
||||||
public String getBrokerName() {
|
public String getBrokerName() {
|
||||||
return brokerName;
|
return brokerName;
|
||||||
}
|
}
|
||||||
|
@ -774,84 +797,82 @@ public class BrokerService implements Service, Serializable {
|
||||||
|
|
||||||
protected void registerConnectorMBean(TransportConnector connector, ObjectName objectName) throws IOException, URISyntaxException {
|
protected void registerConnectorMBean(TransportConnector connector, ObjectName objectName) throws IOException, URISyntaxException {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
ConnectorViewMBean view = new ConnectorView(connector);
|
if (mbeanServer != null) {
|
||||||
try {
|
ConnectorViewMBean view = new ConnectorView(connector);
|
||||||
mbeanServer.registerMBean(view, objectName);
|
try {
|
||||||
registeredMBeanNames.add(objectName);
|
mbeanServer.registerMBean(view, objectName);
|
||||||
}
|
registeredMBeanNames.add(objectName);
|
||||||
catch (Throwable e) {
|
}
|
||||||
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
catch (Throwable e) {
|
||||||
|
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerNetworkConnectorMBean(NetworkConnector connector) throws IOException {
|
protected void registerNetworkConnectorMBean(NetworkConnector connector) throws IOException {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
NetworkConnectorViewMBean view = new NetworkConnectorView(connector);
|
if (mbeanServer != null) {
|
||||||
try {
|
NetworkConnectorViewMBean view = new NetworkConnectorView(connector);
|
||||||
ObjectName objectName = new ObjectName(
|
try {
|
||||||
managementContext.getJmxDomainName()+":"+
|
ObjectName objectName = new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName="
|
||||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
+ JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=NetworkConnector," + "NetworkConnectorName="
|
||||||
"Type=NetworkConnector,"+
|
+ JMXSupport.encodeObjectNamePart(connector.getName()));
|
||||||
"NetworkConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
mbeanServer.registerMBean(view, objectName);
|
||||||
);
|
registeredMBeanNames.add(objectName);
|
||||||
mbeanServer.registerMBean(view, objectName);
|
}
|
||||||
registeredMBeanNames.add(objectName);
|
catch (Throwable e) {
|
||||||
}
|
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
||||||
catch (Throwable e) {
|
}
|
||||||
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerProxyConnectorMBean(ProxyConnector connector) throws IOException {
|
protected void registerProxyConnectorMBean(ProxyConnector connector) throws IOException {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
ProxyConnectorView view = new ProxyConnectorView(connector);
|
if (mbeanServer != null) {
|
||||||
try {
|
ProxyConnectorView view = new ProxyConnectorView(connector);
|
||||||
ObjectName objectName = new ObjectName(
|
try {
|
||||||
managementContext.getJmxDomainName()+":"+
|
ObjectName objectName = new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName="
|
||||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
+ JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=ProxyConnector," + "ProxyConnectorName="
|
||||||
"Type=ProxyConnector,"+
|
+ JMXSupport.encodeObjectNamePart(connector.getName()));
|
||||||
"ProxyConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
mbeanServer.registerMBean(view, objectName);
|
||||||
);
|
registeredMBeanNames.add(objectName);
|
||||||
mbeanServer.registerMBean(view, objectName);
|
}
|
||||||
registeredMBeanNames.add(objectName);
|
catch (Throwable e) {
|
||||||
}
|
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
||||||
catch (Throwable e) {
|
}
|
||||||
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerFTConnectorMBean(MasterConnector connector) throws IOException {
|
protected void registerFTConnectorMBean(MasterConnector connector) throws IOException {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
FTConnectorView view = new FTConnectorView(connector);
|
if (mbeanServer != null) {
|
||||||
try {
|
FTConnectorView view = new FTConnectorView(connector);
|
||||||
ObjectName objectName = new ObjectName(
|
try {
|
||||||
managementContext.getJmxDomainName()+":"+
|
ObjectName objectName = new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName="
|
||||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
+ JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=MasterConnector");
|
||||||
"Type=MasterConnector"
|
mbeanServer.registerMBean(view, objectName);
|
||||||
);
|
registeredMBeanNames.add(objectName);
|
||||||
mbeanServer.registerMBean(view, objectName);
|
}
|
||||||
registeredMBeanNames.add(objectName);
|
catch (Throwable e) {
|
||||||
}
|
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
||||||
catch (Throwable e) {
|
}
|
||||||
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void registerJmsConnectorMBean(JmsConnector connector) throws IOException {
|
protected void registerJmsConnectorMBean(JmsConnector connector) throws IOException {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
JmsConnectorView view = new JmsConnectorView(connector);
|
if (mbeanServer != null) {
|
||||||
try {
|
JmsConnectorView view = new JmsConnectorView(connector);
|
||||||
ObjectName objectName = new ObjectName(
|
try {
|
||||||
managementContext.getJmxDomainName()+":"+
|
ObjectName objectName = new ObjectName(managementContext.getJmxDomainName() + ":" + "BrokerName="
|
||||||
"BrokerName="+JMXSupport.encodeObjectNamePart(getBrokerName())+","+
|
+ JMXSupport.encodeObjectNamePart(getBrokerName()) + "," + "Type=JmsConnector," + "JmsConnectorName="
|
||||||
"Type=JmsConnector,"+
|
+ JMXSupport.encodeObjectNamePart(connector.getName()));
|
||||||
"JmsConnectorName="+JMXSupport.encodeObjectNamePart(connector.getName())
|
mbeanServer.registerMBean(view, objectName);
|
||||||
);
|
registeredMBeanNames.add(objectName);
|
||||||
mbeanServer.registerMBean(view, objectName);
|
}
|
||||||
registeredMBeanNames.add(objectName);
|
catch (Throwable e) {
|
||||||
}
|
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
||||||
catch (Throwable e) {
|
}
|
||||||
throw IOExceptionSupport.create("Broker could not be registered in JMX: " + e.getMessage(), e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -882,11 +903,13 @@ public class BrokerService implements Service, Serializable {
|
||||||
if (isUseJmx()) {
|
if (isUseJmx()) {
|
||||||
ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
|
ManagedRegionBroker managedBroker = (ManagedRegionBroker) regionBroker;
|
||||||
managedBroker.setContextBroker(broker);
|
managedBroker.setContextBroker(broker);
|
||||||
BrokerViewMBean view = new BrokerView(this, managedBroker);
|
adminView = new BrokerView(this, managedBroker);
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
ObjectName objectName = getBrokerObjectName();
|
if (mbeanServer != null) {
|
||||||
mbeanServer.registerMBean(view, objectName);
|
ObjectName objectName = getBrokerObjectName();
|
||||||
registeredMBeanNames.add(objectName);
|
mbeanServer.registerMBean(adminView, objectName);
|
||||||
|
registeredMBeanNames.add(objectName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -908,8 +931,8 @@ public class BrokerService implements Service, Serializable {
|
||||||
RegionBroker regionBroker = null;
|
RegionBroker regionBroker = null;
|
||||||
if (isUseJmx()) {
|
if (isUseJmx()) {
|
||||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||||
regionBroker = new ManagedRegionBroker(this,mbeanServer, getBrokerObjectName(),
|
regionBroker = new ManagedRegionBroker(this, mbeanServer, getBrokerObjectName(), getTaskRunnerFactory(), getMemoryManager(),
|
||||||
getTaskRunnerFactory(), getMemoryManager(), getPersistenceAdapter());
|
getPersistenceAdapter());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
regionBroker = new RegionBroker(this,getTaskRunnerFactory(), getMemoryManager(), getPersistenceAdapter());
|
regionBroker = new RegionBroker(this,getTaskRunnerFactory(), getMemoryManager(), getPersistenceAdapter());
|
||||||
|
@ -1068,7 +1091,7 @@ public class BrokerService implements Service, Serializable {
|
||||||
JmsConnector connector = (JmsConnector) iter.next();
|
JmsConnector connector = (JmsConnector) iter.next();
|
||||||
connector.start();
|
connector.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void startTransportConnector(TransportConnector connector) throws Exception {
|
protected void startTransportConnector(TransportConnector connector) throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue