not far off getting the web console working with remote brokers

git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@504257 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
James Strachan 2007-02-06 19:46:33 +00:00
parent 48f874ca59
commit 156479a33d
4 changed files with 39 additions and 11 deletions

View File

@ -21,7 +21,10 @@ import org.apache.activemq.broker.jmx.BrokerViewMBean;
import org.apache.activemq.broker.jmx.ManagementContext;
import org.apache.activemq.command.ActiveMQDestination;
import java.util.Collection;
import javax.management.MBeanServerConnection;
import javax.management.MBeanServerInvocationHandler;
import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
/**
* A {@link BrokerFacade} which uses JMX to communicate with a remote broker
@ -30,9 +33,11 @@ import java.util.Collection;
*/
public class JMXBrokerFacade extends BrokerFacadeSupport {
private ManagementContext managementContext;
private ObjectName brokerName;
public BrokerViewMBean getBrokerAdmin() throws Exception {
return null; /** TODO */
MBeanServerConnection mbeanServer = getManagementContext().getMBeanServer();
return (BrokerViewMBean) MBeanServerInvocationHandler.newProxyInstance(mbeanServer, getBrokerName(), BrokerViewMBean.class, true);
}
public void purgeQueue(ActiveMQDestination destination) throws Exception {
@ -42,6 +47,7 @@ public class JMXBrokerFacade extends BrokerFacadeSupport {
public ManagementContext getManagementContext() {
if (managementContext == null) {
managementContext = new ManagementContext();
managementContext.setCreateConnector(true);
}
return managementContext;
}
@ -49,4 +55,19 @@ public class JMXBrokerFacade extends BrokerFacadeSupport {
public void setManagementContext(ManagementContext managementContext) {
this.managementContext = managementContext;
}
public ObjectName getBrokerName() throws MalformedObjectNameException {
if (brokerName == null) {
brokerName = createBrokerName();
}
return brokerName;
}
public void setBrokerName(ObjectName brokerName) {
this.brokerName = brokerName;
}
protected ObjectName createBrokerName() throws MalformedObjectNameException {
return new ObjectName(getManagementContext().getJmxDomainName() + ":Type=Broker");
}
}

View File

@ -21,13 +21,20 @@
<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" />
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool"/>
<!-- use the following bean for a local in-JVM broker -->
<bean id="brokerQuery" class="org.apache.activemq.web.LocalBrokerFacade" autowire='constructor' singleton="false"/>
<bean id="brokerService" class="org.apache.activemq.xbean.BrokerFactoryBean">
<property name="config" value="/WEB-INF/activemq.xml"/>
</bean>
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool"/>
<!-- use the following for a remote JMX based broker -->
<!--<bean id="brokerQuery" class="org.apache.activemq.web.JMXBrokerFacade" autowire='constructor' singleton="false"/>-->
<bean id="brokerQuery" class="org.apache.activemq.web.LocalBrokerFacade" autowire='constructor' singleton="false"/>
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire='constructor' singleton="false"/>
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire='constructor' singleton="false"/>

View File

@ -42,7 +42,7 @@ function drawGraph() {
var layout = new PlotKit.Layout("bar", options);
layout.addDataset("sqrt", [<c:forEach items="${requestContext.brokerQuery.queues}" var="row" varStatus="status"><c:if
test="${status.count > 1}">, </c:if> [${status.count}, ${row.destinationStatistics.messages.count}] </c:forEach> ]);
test="${status.count > 1}">, </c:if> [${status.count}, ${row.queueSize}] </c:forEach> ]);
layout.evaluate();
var canvas = MochiKit.DOM.getElement("graph");

View File

@ -19,10 +19,10 @@
<c:forEach items="${requestContext.brokerQuery.queues}" var="row">
<queue name="${row.name}">
<stats size="${row.destinationStatistics.messages.count}"
consumerCount="${row.destinationStatistics.consumers.count}"
enqueueCount="${row.destinationStatistics.enqueues.count}"
dequeueCount="${row.destinationStatistics.dequeues.count}"/>
<stats size="${row.queueSize}"
consumerCount="${row.consumerCount}"
enqueueCount="${row.enqueueCount}"
dequeueCount="${row.dequeueCount}"/>
<feed>