mirror of https://github.com/apache/activemq.git
added in initial support for using a remote JMXBrokerFacade to connect to a remote broker
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@504251 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e17e5eca88
commit
48f874ca59
|
@ -0,0 +1,83 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.web;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.jmx.TopicViewMBean;
|
||||
import org.apache.activemq.broker.jmx.QueueViewMBean;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A useful base class for an implementation of {@link BrokerFacade}
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public abstract class BrokerFacadeSupport implements BrokerFacade {
|
||||
public abstract ManagementContext getManagementContext();
|
||||
|
||||
public Collection getQueues() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getQueues();
|
||||
return getManagedObjects(queues, QueueViewMBean.class);
|
||||
}
|
||||
|
||||
public Collection getTopics() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getTopics();
|
||||
return getManagedObjects(queues, TopicViewMBean.class);
|
||||
}
|
||||
|
||||
public Collection getDurableTopicSubscribers() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getDurableTopicSubscribers();
|
||||
return getManagedObjects(queues, DurableSubscriptionViewMBean.class);
|
||||
}
|
||||
|
||||
protected Collection getManagedObjects(ObjectName[] names, Class type) {
|
||||
List answer = new ArrayList();
|
||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
/**
|
||||
*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.activemq.web;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* A {@link BrokerFacade} which uses JMX to communicate with a remote broker
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class JMXBrokerFacade extends BrokerFacadeSupport {
|
||||
private ManagementContext managementContext;
|
||||
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
return null; /** TODO */
|
||||
}
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
/** TODO */
|
||||
}
|
||||
|
||||
public ManagementContext getManagementContext() {
|
||||
if (managementContext == null) {
|
||||
managementContext = new ManagementContext();
|
||||
}
|
||||
return managementContext;
|
||||
}
|
||||
|
||||
public void setManagementContext(ManagementContext managementContext) {
|
||||
this.managementContext = managementContext;
|
||||
}
|
||||
}
|
|
@ -45,9 +45,7 @@ import java.util.Set;
|
|||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public class LocalBrokerFacade implements BrokerFacade {
|
||||
private static final Log log = LogFactory.getLog(LocalBrokerFacade.class);
|
||||
|
||||
public class LocalBrokerFacade extends BrokerFacadeSupport {
|
||||
private BrokerService brokerService;
|
||||
|
||||
public LocalBrokerFacade(BrokerService brokerService) {
|
||||
|
@ -79,69 +77,6 @@ public class LocalBrokerFacade implements BrokerFacade {
|
|||
return adminView.getBroker();
|
||||
}
|
||||
|
||||
// TODO - we should not have to use JMX to implement the following methods...
|
||||
|
||||
/*
|
||||
public Collection getQueues() throws Exception {
|
||||
BrokerView broker = brokerService.getAdminView();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getQueues();
|
||||
return getManagedObjects(queues, QueueViewMBean.class);
|
||||
}
|
||||
*/
|
||||
public Collection getQueues() throws Exception {
|
||||
ManagedRegionBroker broker = getManagedBroker();
|
||||
if (broker == null) {
|
||||
return new ArrayList();
|
||||
}
|
||||
return broker.getQueueRegion().getDestinationMap().values();
|
||||
}
|
||||
|
||||
|
||||
public Collection getTopics() throws Exception {
|
||||
BrokerView broker = brokerService.getAdminView();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getTopics();
|
||||
return getManagedObjects(queues, TopicViewMBean.class);
|
||||
}
|
||||
|
||||
public Collection getDurableTopicSubscribers() throws Exception {
|
||||
BrokerView broker = brokerService.getAdminView();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
ObjectName[] queues = broker.getDurableTopicSubscribers();
|
||||
return getManagedObjects(queues, DurableSubscriptionViewMBean.class);
|
||||
}
|
||||
|
||||
protected Collection getManagedObjects(ObjectName[] names, Class type) {
|
||||
List answer = new ArrayList();
|
||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
Object value = MBeanServerInvocationHandler.newProxyInstance(mbeanServer, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* public Collection getTopics() throws Exception { ManagedRegionBroker
|
||||
* broker = getManagedBroker(); if (broker == null) { return new
|
||||
* ArrayList(); } return
|
||||
* broker.getTopicRegion().getDestinationMap().values(); }
|
||||
*/
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination);
|
||||
for (Iterator i=destinations.iterator(); i.hasNext();) {
|
||||
|
|
|
@ -54,10 +54,10 @@
|
|||
<c:forEach items="${requestContext.brokerQuery.queues}" var="row">
|
||||
<tr>
|
||||
<td><a href="browse.jsp?JMSDestination=${row.name}">${row.name}</a></td>
|
||||
<td>${row.destinationStatistics.messages.count}</td>
|
||||
<td>${row.destinationStatistics.consumers.count}</td>
|
||||
<td>${row.destinationStatistics.enqueues.count}</td>
|
||||
<td>${row.destinationStatistics.dequeues.count}</td>
|
||||
<td>${row.queueSize}</td>
|
||||
<td>${row.consumerCount}</td>
|
||||
<td>${row.enqueueCount}</td>
|
||||
<td>${row.dequeueCount}</td>
|
||||
<td>
|
||||
<a href="browse.jsp?JMSDestination=${row.name}">Browse</a>
|
||||
<%--
|
||||
|
|
Loading…
Reference in New Issue