mirror of https://github.com/apache/activemq.git
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@751656 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
6d9163af39
commit
b514d3fb4b
|
@ -18,8 +18,9 @@
|
|||
#
|
||||
# The logging properties used during tests..
|
||||
#
|
||||
log4j.rootLogger=DEBUG, stdout
|
||||
log4j.rootLogger=INFO, stdout
|
||||
|
||||
log4j.logger.org.apache.activemq=INFO
|
||||
log4j.logger.org.apache.activemq.spring=WARN
|
||||
log4j.logger.org.springframework=warn
|
||||
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
<%--
|
||||
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.
|
||||
--%>
|
||||
<%@ attribute name="connection" type="java.lang.String" required="true" %>
|
||||
<%@ attribute name="connectionName" type="java.lang.String" required="true" %>
|
||||
<%@ attribute name="broker" type="org.apache.activemq.web.BrokerFacade" required="true" %>
|
||||
<%@ attribute name="connectorName" type="java.lang.String" required="true" %>
|
||||
<%@ tag import="java.util.Iterator" %>
|
||||
<%@ tag import="org.apache.activemq.broker.jmx.ConnectionViewMBean" %>
|
||||
<%
|
||||
Iterator it = broker.getConnections(connectorName).iterator();
|
||||
while (it.hasNext()) {
|
||||
String conName = (String) it.next();
|
||||
ConnectionViewMBean con = broker.getConnection(conName);
|
||||
request.setAttribute(connectionName, conName);
|
||||
request.setAttribute(connection, con);
|
||||
%>
|
||||
<jsp:doBody/>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
|
|
@ -40,5 +40,7 @@
|
|||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="queueConsumerQuery" class="org.apache.activemq.web.QueueConsumerQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="connectionQuery" class="org.apache.activemq.web.ConnectionQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -39,5 +39,7 @@
|
|||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="queueConsumerQuery" class="org.apache.activemq.web.QueueConsumerQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="connectionQuery" class="org.apache.activemq.web.ConnectionQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -27,20 +27,17 @@
|
|||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="configuration" class="org.apache.activemq.web.config.JNDIConfiguration"/>
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.RemoteJMXBrokerFacade" autowire="constructor" destroy-method="shutdown">
|
||||
<property name="jmxUrl" ref="jmxUrl"/>
|
||||
<property name="configuration" ref="configuration"/>
|
||||
<property name="brokerName"><null/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="jmxUrl" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="java:comp/env/jmx/url" />
|
||||
</bean>
|
||||
<bean id="connectionFactory" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||||
<property name="jndiName" value="java:comp/env/jms/connectionFactory" />
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" factory-bean="configuration" factory-method="getConnectionFactory"/>
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
<bean id="queueConsumerQuery" class="org.apache.activemq.web.QueueConsumerQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="connectionQuery" class="org.apache.activemq.web.ConnectionQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
</beans>
|
||||
|
|
|
@ -26,20 +26,19 @@
|
|||
<bean id="sessionPool" class="org.apache.activemq.web.SessionPool">
|
||||
<property name="connectionFactory" ref="connectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<bean id="configuration" class="org.apache.activemq.web.config.SystemPropertiesConfiguration"/>
|
||||
|
||||
<bean id="brokerQuery" class="org.apache.activemq.web.RemoteJMXBrokerFacade" autowire="constructor" destroy-method="shutdown">
|
||||
<property name="jmxUrl" value="${webconsole.jmx.url}"/>
|
||||
<property name="jmxRole" value="${webconsole.jmx.role}"/>
|
||||
<property name="jmxPassword" value="${webconsole.jmx.password}"/>
|
||||
<property name="configuration" ref="configuration"/>
|
||||
<property name="brokerName"><null/></property>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="${webconsole.jms.url}"/>
|
||||
</bean>
|
||||
|
||||
<bean id="connectionFactory" factory-bean="configuration" factory-method="getConnectionFactory"/>
|
||||
|
||||
<bean id="queueBrowser" class="org.apache.activemq.web.QueueBrowseQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="messageQuery" class="org.apache.activemq.web.MessageQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="queueConsumerQuery" class="org.apache.activemq.web.QueueConsumerQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
<bean id="connectionQuery" class="org.apache.activemq.web.ConnectionQuery" autowire="constructor" destroy-method="destroy" scope="request"/>
|
||||
|
||||
</beans>
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<%--
|
||||
<c:forEach items="${requestContext.queueBrowser.browser.enumeration}" var="row">
|
||||
---%>
|
||||
<jms:forEachMessage queueBrowser="${requestContext.queueBrowser.browser}" var="row">
|
||||
<tr>
|
||||
<td><a href="message.jsp?id=${row.JMSMessageID}&JMSDestination=${requestContext.queueBrowser.JMSDestination}"
|
||||
|
@ -56,13 +53,12 @@
|
|||
</td>
|
||||
</tr>
|
||||
</jms:forEachMessage>
|
||||
<%--
|
||||
</c:forEach>
|
||||
--%>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
<div>
|
||||
<a href="queueConsumers.jsp?JMSDestination=${requestContext.queueBrowser.JMSDestination}">View Consumers</a>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -0,0 +1,150 @@
|
|||
<%--
|
||||
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.
|
||||
--%>
|
||||
<html>
|
||||
<head>
|
||||
<c:set var="row" value="${requestContext.connectionQuery.connection}"/>
|
||||
<title>Connection ${requestContext.connectionQuery.connectionID}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
<c:choose>
|
||||
<c:when test="${empty row}">
|
||||
|
||||
<div>
|
||||
No connection could be found for ID ${requestContext.connectionQuery.connectionID}
|
||||
</div>
|
||||
|
||||
</c:when>
|
||||
|
||||
<c:otherwise>
|
||||
|
||||
<h2>Connection ${requestContext.connectionQuery.connectionID}</h2>
|
||||
|
||||
<table id="header" class="sortable autostripe">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="label" title="Unique ID for this connection">Connection ID</td>
|
||||
<td>${requestContext.connectionQuery.connectionID}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" tite="Hostname and port of the connected party">Remote Address</td>
|
||||
<td>${row.remoteAddress}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Active</td>
|
||||
<td>${row.active}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Connected</td>
|
||||
<td>${row.connected}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Blocked</td>
|
||||
<td>${row.blocked}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Slow</td>
|
||||
<td>${row.slow}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Enqueue Count</td>
|
||||
<td>${row.enqueueCount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Dequeue Count</td>
|
||||
<td>${row.dequeueCount}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">Dispatch Queue Size</td>
|
||||
<td>${row.dispatchQueueSize}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
<h3>Consumers</h3>
|
||||
|
||||
<table id="messages" class="sortable autostripe">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Destination</th>
|
||||
<th>SessionId</th>
|
||||
<th>Selector</th>
|
||||
<th>Enqueues</th>
|
||||
<th>Dequeues</th>
|
||||
<th>Dispatched</th>
|
||||
<th>Dispatched Queue</th>
|
||||
<th>
|
||||
<span>Prefetch</span>
|
||||
<br/>
|
||||
<span>Max pending</span>
|
||||
</th>
|
||||
<th>
|
||||
<span>Exclusive</span>
|
||||
<br/>
|
||||
<span>Retroactive</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${requestContext.connectionQuery.consumers}" var="consumer">
|
||||
<tr>
|
||||
<td>
|
||||
<c:choose>
|
||||
<c:when test="${consumer.destinationQueue}">
|
||||
Queue <a href="browse.jsp?JMSDestination=${consumer.destinationName}">${consumer.destinationName}</a>
|
||||
</c:when>
|
||||
<c:when test="${consumer.destinationTopic}">
|
||||
Topic <a href="send.jsp?JMSDestination=${consumer.destinationName}">${consumer.destinationName}</a>
|
||||
</c:when>
|
||||
<c:otherwise>
|
||||
${consumer.destinationName}
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
</td>
|
||||
<td>${consumer.sessionId}</td>
|
||||
<td>${consumer.selector}</td>
|
||||
<td>${consumer.enqueueCounter}</td>
|
||||
<td>${consumer.dequeueCounter}</td>
|
||||
<td>${consumer.dispachedCounter}</td>
|
||||
<td>${consumer.dispatchedQueueSize}</td>
|
||||
<td>
|
||||
${consumer.prefetchSize}<br/>
|
||||
${consumer.maximumPendingMessageLimit}
|
||||
</td>
|
||||
<td>
|
||||
${consumer.exclusive}<br/>
|
||||
${consumer.retroactive}
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
</c:otherwise>
|
||||
</c:choose>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,91 @@
|
|||
<%--
|
||||
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.
|
||||
--%>
|
||||
<html>
|
||||
<head>
|
||||
<title>Connections</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Connections</h2>
|
||||
|
||||
<c:forEach items="${requestContext.brokerQuery.connectors}" var="connectorName">
|
||||
<h3>Connector ${connectorName}</h3>
|
||||
|
||||
<table id="connections" class="sortable autostripe">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Remote Address</th>
|
||||
<th>Enqueue Count</th>
|
||||
<th>Dequeue Count</th>
|
||||
<th>Dispatch Queue Size</th>
|
||||
<th>Active</th>
|
||||
<th>Slow</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<jms:forEachConnection broker="${requestContext.brokerQuery}" connectorName="${connectorName}"
|
||||
connection="con" connectionName="conName">
|
||||
<tr>
|
||||
<td><a href="connection.jsp?connectionID=${conName}">${conName}</a></td>
|
||||
<td>${con.remoteAddress}</td>
|
||||
<td>${con.enqueueCount}</td>
|
||||
<td>${con.dequeueCount}</td>
|
||||
<td>${con.dispatchQueueSize}</td>
|
||||
<td>${con.active}</td>
|
||||
<td>${con.slow}</td>
|
||||
</tr>
|
||||
</jms:forEachConnection>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</c:forEach>
|
||||
|
||||
<div style="margin-top: 5em">
|
||||
<h2>Network Connectors</h2>
|
||||
|
||||
<table id="connections" class="sortable autostripe">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Network TTL</th>
|
||||
<th>Dynamic Only</th>
|
||||
<th>Conduit Subscriptions</th>
|
||||
<th>Bridge Temps</th>
|
||||
<th>Decrease Priorities</th>
|
||||
<th>Dispatch Async</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${requestContext.brokerQuery.networkConnectors}" var="nc">
|
||||
<tr>
|
||||
<td>${nc.name}</td>
|
||||
<td>${nc.networkTTL}</td>
|
||||
<td>${nc.dynamicOnly}</td>
|
||||
<td>${nc.conduitSubscriptions}</td>
|
||||
<td>${nc.bridgeTempDestinations}</td>
|
||||
<td>${nc.decreaseNetworkConsumerPriority}</td>
|
||||
<td>${nc.dispatchAsync}</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -72,6 +72,8 @@
|
|||
|
|
||||
<a href="<c:url value='/subscribers.jsp'/>" title="Subscribers">Subscribers</a>
|
||||
|
|
||||
<a href="<c:url value='/connections.jsp'/>" title="Connections">Connections</a>
|
||||
|
|
||||
<a href="<c:url value='/send.jsp'/>"
|
||||
title="Send">Send</a>
|
||||
</div>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<h2>Welcome!</h2>
|
||||
|
||||
<p>
|
||||
Welcome to the ActiveMQ Console
|
||||
Welcome to the ActiveMQ Console of <b>${requestContext.brokerQuery.brokerName}</b> (${requestContext.brokerQuery.brokerAdmin.brokerId})
|
||||
</p>
|
||||
|
||||
<p>
|
||||
|
|
|
@ -0,0 +1,79 @@
|
|||
<%--
|
||||
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.
|
||||
--%>
|
||||
<html>
|
||||
<head>
|
||||
<title>Consumers for ${requestContext.queueConsumerQuery.JMSDestination}</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h2>Active Consumers for ${requestContext.queueConsumerQuery.JMSDestination}</h2>
|
||||
|
||||
<table id="messages" class="sortable autostripe">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<span>Client ID</span>
|
||||
<br/>
|
||||
<span>Connection ID</span>
|
||||
</th>
|
||||
<th>SessionId</th>
|
||||
<th>Selector</th>
|
||||
<th>Enqueues</th>
|
||||
<th>Dequeues</th>
|
||||
<th>Dispatched</th>
|
||||
<th>Dispatched Queue</th>
|
||||
<th>
|
||||
<span>Prefetch</span>
|
||||
<br/>
|
||||
<span>Max pending</span>
|
||||
</th>
|
||||
<th>
|
||||
<span>Exclusive</span>
|
||||
<br/>
|
||||
<span>Retroactive</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<c:forEach items="${requestContext.queueConsumerQuery.consumers}" var="row">
|
||||
<tr>
|
||||
<td>
|
||||
<a href="connection.jsp?connectionID=${row.clientId}">${row.clientId}</a><br/>
|
||||
${row.connectionId}</a>
|
||||
</td>
|
||||
<td>${row.sessionId}</td>
|
||||
<td>${row.selector}</td>
|
||||
<td>${row.enqueueCounter}</td>
|
||||
<td>${row.dequeueCounter}</td>
|
||||
<td>${row.dispachedCounter}</td>
|
||||
<td>${row.dispatchedQueueSize}</td>
|
||||
<td>
|
||||
${row.prefetchSize}<br/>
|
||||
${row.maximumPendingMessageLimit}
|
||||
</td>
|
||||
<td>
|
||||
${row.exclusive}<br/>
|
||||
${row.retroactive}
|
||||
</td>
|
||||
</tr>
|
||||
</c:forEach>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -56,9 +56,7 @@
|
|||
<td>${row.dequeueCount}</td>
|
||||
<td>
|
||||
<a href="browse.jsp?JMSDestination=${row.name}">Browse</a>
|
||||
<%--
|
||||
<a href="graph.jsp?JMSDestination=${row.name}">Graph</a>
|
||||
--%>
|
||||
<a href="queueConsumers.jsp?JMSDestination=${row.name}">Active Consumers</a><br/>
|
||||
<a href="queueBrowse/${row.name}?view=rss&feedType=atom_1.0" title="Atom 1.0"><img src="images/feed_atom.png"/></a>
|
||||
<a href="queueBrowse/${row.name}?view=rss&feedType=rss_2.0" title="RSS 2.0"><img src="images/feed_rss.png"/></a>
|
||||
</td>
|
||||
|
|
|
@ -19,33 +19,163 @@ package org.apache.activemq.web;
|
|||
import java.util.Collection;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ConnectionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ConnectorViewMBean;
|
||||
import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean;
|
||||
import org.apache.activemq.broker.jmx.QueueViewMBean;
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.TopicViewMBean;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
|
||||
/**
|
||||
* A facade for either a local in JVM broker or a remote broker over JMX
|
||||
*
|
||||
*
|
||||
* @version $Revision$
|
||||
*/
|
||||
public interface BrokerFacade {
|
||||
|
||||
BrokerViewMBean getBrokerAdmin() throws Exception;
|
||||
/**
|
||||
* The name of the active broker (f.e. 'localhost' or 'my broker').
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
String getBrokerName() throws Exception;
|
||||
|
||||
Collection getQueues() throws Exception;
|
||||
/**
|
||||
* Admin view of the broker.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
BrokerViewMBean getBrokerAdmin() throws Exception;
|
||||
|
||||
Collection getTopics() throws Exception;
|
||||
/**
|
||||
* All queues known to the broker.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<QueueViewMBean> getQueues() throws Exception;
|
||||
|
||||
Collection getDurableTopicSubscribers() throws Exception;
|
||||
/**
|
||||
* All topics known to the broker.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<TopicViewMBean> getTopics() throws Exception;
|
||||
|
||||
/**
|
||||
* Purges the given destination
|
||||
* @param destination
|
||||
* @throws Exception
|
||||
*/
|
||||
void purgeQueue(ActiveMQDestination destination) throws Exception;
|
||||
/**
|
||||
* All active consumers of a queue.
|
||||
*
|
||||
* @param queueName
|
||||
* the name of the queue, not <code>null</code>
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<SubscriptionViewMBean> getQueueConsumers(String queueName)
|
||||
throws Exception;
|
||||
|
||||
QueueViewMBean getQueue(String name) throws Exception;
|
||||
/**
|
||||
* All durable subscribers to topics of the broker.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<DurableSubscriptionViewMBean> getDurableTopicSubscribers()
|
||||
throws Exception;
|
||||
|
||||
TopicViewMBean getTopic(String name) throws Exception;
|
||||
}
|
||||
/**
|
||||
* The names of all transport connectors of the broker (f.e. openwire, ssl)
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<String> getConnectors() throws Exception;
|
||||
|
||||
/**
|
||||
* A transport connectors.
|
||||
*
|
||||
* @param name
|
||||
* name of the connector (f.e. openwire)
|
||||
* @return <code>null</code> if not found
|
||||
* @throws Exception
|
||||
*/
|
||||
ConnectorViewMBean getConnector(String name) throws Exception;
|
||||
|
||||
/**
|
||||
* All connections to all transport connectors of the broker.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<ConnectionViewMBean> getConnections() throws Exception;
|
||||
|
||||
/**
|
||||
* The names of all connections to a specific transport connectors of the
|
||||
* broker.
|
||||
*
|
||||
* @see #getConnection(String)
|
||||
* @param connectorName
|
||||
* not <code>null</code>
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<String> getConnections(String connectorName) throws Exception;
|
||||
|
||||
/**
|
||||
* A specific connection to the broker.
|
||||
*
|
||||
* @param connectionName
|
||||
* the name of the connection, not <code>null</code>
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
ConnectionViewMBean getConnection(String connectionName) throws Exception;
|
||||
/**
|
||||
* Returns all consumers of a connection.
|
||||
*
|
||||
* @param connectionName
|
||||
* the name of the connection, not <code>null</code>
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<SubscriptionViewMBean> getConsumersOnConnection(
|
||||
String connectionName) throws Exception;
|
||||
/**
|
||||
* The brokers network connectors.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
Collection<NetworkConnectorViewMBean> getNetworkConnectors()
|
||||
throws Exception;
|
||||
/**
|
||||
* Purges the given destination
|
||||
*
|
||||
* @param destination
|
||||
* @throws Exception
|
||||
*/
|
||||
void purgeQueue(ActiveMQDestination destination) throws Exception;
|
||||
/**
|
||||
* Get the view of the queue with the specified name.
|
||||
*
|
||||
* @param name
|
||||
* not <code>null</code>
|
||||
* @return <code>null</code> if no queue with this name exists
|
||||
* @throws Exception
|
||||
*/
|
||||
QueueViewMBean getQueue(String name) throws Exception;
|
||||
/**
|
||||
* Get the view of the topic with the specified name.
|
||||
*
|
||||
* @param name
|
||||
* not <code>null</code>
|
||||
* @return <code>null</code> if no topic with this name exists
|
||||
* @throws Exception
|
||||
*/
|
||||
TopicViewMBean getTopic(String name) throws Exception;
|
||||
}
|
|
@ -21,17 +21,24 @@ import java.util.Collection;
|
|||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MBeanServerConnection;
|
||||
import javax.management.MBeanServerInvocationHandler;
|
||||
import javax.management.ObjectName;
|
||||
|
||||
import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ConnectionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ConnectorViewMBean;
|
||||
import org.apache.activemq.broker.jmx.DestinationViewMBean;
|
||||
import org.apache.activemq.broker.jmx.DurableSubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.jmx.NetworkConnectorViewMBean;
|
||||
import org.apache.activemq.broker.jmx.QueueViewMBean;
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.TopicViewMBean;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* A useful base class for an implementation of {@link BrokerFacade}
|
||||
|
@ -41,7 +48,7 @@ import org.apache.activemq.broker.jmx.TopicViewMBean;
|
|||
public abstract class BrokerFacadeSupport implements BrokerFacade {
|
||||
public abstract ManagementContext getManagementContext();
|
||||
|
||||
public Collection<Object> getQueues() throws Exception {
|
||||
public Collection<QueueViewMBean> getQueues() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
|
@ -50,7 +57,7 @@ public abstract class BrokerFacadeSupport implements BrokerFacade {
|
|||
return getManagedObjects(queues, QueueViewMBean.class);
|
||||
}
|
||||
|
||||
public Collection<Object> getTopics() throws Exception {
|
||||
public Collection<TopicViewMBean> getTopics() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
|
@ -59,7 +66,7 @@ public abstract class BrokerFacadeSupport implements BrokerFacade {
|
|||
return getManagedObjects(queues, TopicViewMBean.class);
|
||||
}
|
||||
|
||||
public Collection<Object> getDurableTopicSubscribers() throws Exception {
|
||||
public Collection<DurableSubscriptionViewMBean> getDurableTopicSubscribers() throws Exception {
|
||||
BrokerViewMBean broker = getBrokerAdmin();
|
||||
if (broker == null) {
|
||||
return Collections.EMPTY_LIST;
|
||||
|
@ -76,29 +83,162 @@ public abstract class BrokerFacadeSupport implements BrokerFacade {
|
|||
return (TopicViewMBean) getDestinationByName(getTopics(), name);
|
||||
}
|
||||
|
||||
protected DestinationViewMBean getDestinationByName(Collection<Object> collection, String name) {
|
||||
Iterator<Object> iter = collection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
DestinationViewMBean destinationViewMBean = (DestinationViewMBean) iter.next();
|
||||
if (name.equals(destinationViewMBean.getName())) {
|
||||
return destinationViewMBean;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
protected DestinationViewMBean getDestinationByName(
|
||||
Collection<? extends DestinationViewMBean> collection, String name) {
|
||||
Iterator<? extends DestinationViewMBean> iter = collection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
DestinationViewMBean destinationViewMBean = iter.next();
|
||||
if (name.equals(destinationViewMBean.getName())) {
|
||||
return destinationViewMBean;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> Collection<T> getManagedObjects(ObjectName[] names,
|
||||
Class<T> type) {
|
||||
List<T> answer = new ArrayList<T>();
|
||||
MBeanServer mbeanServer = getManagementContext().getMBeanServer();
|
||||
if (mbeanServer != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
T value = (T) MBeanServerInvocationHandler.newProxyInstance(
|
||||
mbeanServer, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the MBeanServer connection.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
* @throws Exception
|
||||
*/
|
||||
protected MBeanServerConnection getMBeanServerConnection() throws Exception {
|
||||
return getManagementContext().getMBeanServer();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<ConnectionViewMBean> getConnections() throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=Connection,*");
|
||||
System.out.println(query);
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult
|
||||
.size()]), ConnectionViewMBean.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<String> getConnections(String connectorName)
|
||||
throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=Connection,ConnectorName="
|
||||
+ connectorName + ",*");
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
|
||||
Collection<String> result = new ArrayList<String>(queryResult.size());
|
||||
for (ObjectName on : queryResult) {
|
||||
String name = StringUtils.replace(on.getKeyProperty("Connection"),
|
||||
"_", ":");
|
||||
result.add(name);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public ConnectionViewMBean getConnection(String connectionName)
|
||||
throws Exception {
|
||||
connectionName = StringUtils.replace(connectionName, ":", "_");
|
||||
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=Connection,*,Connection="
|
||||
+ connectionName);
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
if (queryResult.size() == 0)
|
||||
return null;
|
||||
ObjectName objectName = queryResult.iterator().next();
|
||||
return (ConnectionViewMBean) MBeanServerInvocationHandler
|
||||
.newProxyInstance(connection, objectName,
|
||||
ConnectionViewMBean.class, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<String> getConnectors() throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=Connector,*");
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
|
||||
Collection<String> result = new ArrayList<String>(queryResult.size());
|
||||
for (ObjectName on : queryResult)
|
||||
result.add(on.getKeyProperty("ConnectorName"));
|
||||
return result;
|
||||
}
|
||||
|
||||
public ConnectorViewMBean getConnector(String name) throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName objectName = new ObjectName(
|
||||
"org.apache.activemq:BrokerName=" + brokerName
|
||||
+ ",Type=Connector,ConnectorName=" + name);
|
||||
return (ConnectorViewMBean) MBeanServerInvocationHandler
|
||||
.newProxyInstance(connection, objectName,
|
||||
ConnectorViewMBean.class, true);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<NetworkConnectorViewMBean> getNetworkConnectors()
|
||||
throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=NetworkConnector,*");
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult
|
||||
.size()]), NetworkConnectorViewMBean.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<SubscriptionViewMBean> getQueueConsumers(String queueName)
|
||||
throws Exception {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName
|
||||
+ ",Type=Subscription,destinationType=Queue,destinationName="
|
||||
+ queueName + ",*");
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult
|
||||
.size()]), SubscriptionViewMBean.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public Collection<SubscriptionViewMBean> getConsumersOnConnection(
|
||||
String connectionName) throws Exception {
|
||||
connectionName = StringUtils.replace(connectionName, ":", "_");
|
||||
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
String brokerName = getBrokerName();
|
||||
ObjectName query = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ brokerName + ",Type=Subscription,clientId=" + connectionName
|
||||
+ ",*");
|
||||
Set<ObjectName> queryResult = connection.queryNames(query, null);
|
||||
return getManagedObjects(queryResult.toArray(new ObjectName[queryResult
|
||||
.size()]), SubscriptionViewMBean.class);
|
||||
}
|
||||
|
||||
|
||||
protected Collection<Object> getManagedObjects(ObjectName[] names, Class type) {
|
||||
List<Object> answer = new ArrayList<Object>();
|
||||
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,49 @@
|
|||
package org.apache.activemq.web;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
import org.apache.activemq.broker.jmx.ConnectionViewMBean;
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
|
||||
/**
|
||||
* Query for a single connection.
|
||||
*
|
||||
* @author ms
|
||||
*/
|
||||
public class ConnectionQuery {
|
||||
|
||||
private final BrokerFacade mBrokerFacade;
|
||||
private String mConnectionID;
|
||||
|
||||
public ConnectionQuery(BrokerFacade brokerFacade) {
|
||||
mBrokerFacade = brokerFacade;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
// empty
|
||||
}
|
||||
|
||||
public void setConnectionID(String connectionID) {
|
||||
mConnectionID = connectionID;
|
||||
}
|
||||
|
||||
public String getConnectionID() {
|
||||
return mConnectionID;
|
||||
}
|
||||
|
||||
public ConnectionViewMBean getConnection() throws Exception {
|
||||
String connectionID = getConnectionID();
|
||||
if (connectionID == null)
|
||||
return null;
|
||||
return mBrokerFacade.getConnection(connectionID);
|
||||
}
|
||||
|
||||
public Collection<SubscriptionViewMBean> getConsumers() throws Exception {
|
||||
String connectionID = getConnectionID();
|
||||
if (connectionID == null)
|
||||
return Collections.emptyList();
|
||||
return mBrokerFacade.getConsumersOnConnection(connectionID);
|
||||
}
|
||||
|
||||
}
|
|
@ -34,36 +34,34 @@ import org.apache.activemq.command.ActiveMQDestination;
|
|||
* @version $Revision$
|
||||
*/
|
||||
public class LocalBrokerFacade extends BrokerFacadeSupport {
|
||||
private BrokerService brokerService;
|
||||
private BrokerService brokerService;
|
||||
|
||||
public LocalBrokerFacade(BrokerService brokerService) {
|
||||
this.brokerService = brokerService;
|
||||
}
|
||||
public LocalBrokerFacade(BrokerService brokerService) {
|
||||
this.brokerService = brokerService;
|
||||
}
|
||||
|
||||
public BrokerService getBrokerService() {
|
||||
return brokerService;
|
||||
}
|
||||
|
||||
public Broker getBroker() throws Exception {
|
||||
return brokerService.getBroker();
|
||||
}
|
||||
|
||||
public ManagementContext getManagementContext() {
|
||||
return brokerService.getManagementContext();
|
||||
}
|
||||
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
// TODO could use JMX to look this up
|
||||
return brokerService.getAdminView();
|
||||
}
|
||||
|
||||
public ManagedRegionBroker getManagedBroker() throws Exception {
|
||||
BrokerView adminView = brokerService.getAdminView();
|
||||
if (adminView == null) {
|
||||
return null;
|
||||
}
|
||||
return adminView.getBroker();
|
||||
}
|
||||
public BrokerService getBrokerService() {
|
||||
return brokerService;
|
||||
}
|
||||
public String getBrokerName() throws Exception {
|
||||
return brokerService.getBrokerName();
|
||||
}
|
||||
public Broker getBroker() throws Exception {
|
||||
return brokerService.getBroker();
|
||||
}
|
||||
public ManagementContext getManagementContext() {
|
||||
return brokerService.getManagementContext();
|
||||
}
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
return brokerService.getAdminView();
|
||||
}
|
||||
public ManagedRegionBroker getManagedBroker() throws Exception {
|
||||
BrokerView adminView = brokerService.getAdminView();
|
||||
if (adminView == null) {
|
||||
return null;
|
||||
}
|
||||
return adminView.getBroker();
|
||||
}
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
Set destinations = getManagedBroker().getQueueRegion().getDestinations(destination);
|
||||
|
@ -72,4 +70,5 @@ public class LocalBrokerFacade extends BrokerFacadeSupport {
|
|||
regionQueue.purge();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* 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 java.util.Collection;
|
||||
|
||||
import javax.jms.JMSException;
|
||||
|
||||
import org.apache.activemq.broker.jmx.SubscriptionViewMBean;
|
||||
|
||||
/**
|
||||
* Query for Queue consumers.
|
||||
*
|
||||
* @version $Revision: 504235 $
|
||||
*/
|
||||
public class QueueConsumerQuery extends DestinationFacade {
|
||||
|
||||
public QueueConsumerQuery(BrokerFacade brokerFacade) throws JMSException {
|
||||
super(brokerFacade);
|
||||
setJMSDestinationType("queue");
|
||||
}
|
||||
|
||||
public Collection<SubscriptionViewMBean> getConsumers() throws Exception {
|
||||
return getBrokerFacade().getQueueConsumers(getJMSDestination());
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
// empty
|
||||
}
|
||||
|
||||
}
|
|
@ -21,6 +21,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.management.MBeanServerConnection;
|
||||
|
@ -35,6 +36,7 @@ import org.apache.activemq.broker.jmx.BrokerViewMBean;
|
|||
import org.apache.activemq.broker.jmx.ManagementContext;
|
||||
import org.apache.activemq.broker.jmx.QueueViewMBean;
|
||||
import org.apache.activemq.command.ActiveMQDestination;
|
||||
import org.apache.activemq.web.config.WebConsoleConfiguration;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
|
@ -48,34 +50,30 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
|
|||
|
||||
private static final transient Log LOG = LogFactory.getLog(RemoteJMXBrokerFacade.class);
|
||||
|
||||
private String jmxUrl;
|
||||
private String jmxRole;
|
||||
private String jmxPassword;
|
||||
private String brokerName;
|
||||
private JMXConnector connector;
|
||||
private WebConsoleConfiguration configuration;
|
||||
|
||||
public void setBrokerName(String brokerName) {
|
||||
this.brokerName = brokerName;
|
||||
}
|
||||
|
||||
public void setJmxUrl(String url) {
|
||||
this.jmxUrl = url;
|
||||
}
|
||||
|
||||
public void setJmxRole(String role) {
|
||||
this.jmxRole = role;
|
||||
}
|
||||
|
||||
public void setJmxPassword(String password) {
|
||||
this.jmxPassword = password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shutdown this facade aka close any open connection.
|
||||
*/
|
||||
public void shutdown() {
|
||||
closeConnection();
|
||||
}
|
||||
|
||||
private ObjectName getBrokerObjectName(MBeanServerConnection connection)
|
||||
throws IOException, MalformedObjectNameException {
|
||||
Set<ObjectName> brokers = findBrokers(connection);
|
||||
if (brokers.size() == 0) {
|
||||
throw new IOException("No broker could be found in the JMX.");
|
||||
}
|
||||
ObjectName name = brokers.iterator().next();
|
||||
return name;
|
||||
}
|
||||
|
||||
public BrokerViewMBean getBrokerAdmin() throws Exception {
|
||||
MBeanServerConnection connection = getConnection();
|
||||
|
@ -89,6 +87,14 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
|
|||
return mbean;
|
||||
}
|
||||
|
||||
public String getBrokerName() throws Exception,
|
||||
MalformedObjectNameException {
|
||||
MBeanServerConnection connection = getMBeanServerConnection();
|
||||
ObjectName brokerObjectName = getBrokerObjectName(connection);
|
||||
String brokerName = brokerObjectName.getKeyProperty("BrokerName");
|
||||
return brokerName;
|
||||
}
|
||||
|
||||
protected MBeanServerConnection getConnection() throws IOException {
|
||||
JMXConnector connector = this.connector;
|
||||
if (isConnectionActive(connector)) {
|
||||
|
@ -119,44 +125,43 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
|
|||
}
|
||||
|
||||
protected JMXConnector createConnection() {
|
||||
String[] urls = this.jmxUrl.split(",");
|
||||
HashMap env = new HashMap();
|
||||
env.put("jmx.remote.credentials", new String[] {
|
||||
this.jmxRole, this.jmxPassword
|
||||
});
|
||||
|
||||
if (urls == null || urls.length == 0) {
|
||||
urls = new String[] {
|
||||
this.jmxUrl
|
||||
};
|
||||
}
|
||||
Map<String, Object> env = new HashMap<String, Object>();
|
||||
if (this.configuration.getJmxUser() != null) {
|
||||
env.put("jmx.remote.credentials", new String[] {
|
||||
this.configuration.getJmxUser(),
|
||||
this.configuration.getJmxPassword() });
|
||||
}
|
||||
Collection<JMXServiceURL> jmxUrls = this.configuration.getJmxUrls();
|
||||
|
||||
Exception exception = null;
|
||||
for (int i = 0; i < urls.length; i++) {
|
||||
try {
|
||||
JMXConnector connector = JMXConnectorFactory.connect(new JMXServiceURL(urls[i]), env);
|
||||
connector.connect();
|
||||
MBeanServerConnection connection = connector.getMBeanServerConnection();
|
||||
for (JMXServiceURL url : jmxUrls) {
|
||||
try {
|
||||
JMXConnector connector = JMXConnectorFactory.connect(url, env);
|
||||
connector.connect();
|
||||
MBeanServerConnection connection = connector
|
||||
.getMBeanServerConnection();
|
||||
|
||||
Set brokers = findBrokers(connection);
|
||||
if (brokers.size() > 0) {
|
||||
LOG.info("Connected via JMX to the broker at " + urls[i]);
|
||||
return connector;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Keep the exception for later
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException)exception;
|
||||
} else {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No broker is found at any of the urls " + this.jmxUrl);
|
||||
}
|
||||
Set<ObjectName> brokers = findBrokers(connection);
|
||||
if (brokers.size() > 0) {
|
||||
LOG.info("Connected via JMX to the broker at " + url);
|
||||
return connector;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// Keep the exception for later
|
||||
exception = e;
|
||||
}
|
||||
}
|
||||
if (exception != null) {
|
||||
if (exception instanceof RuntimeException) {
|
||||
throw (RuntimeException) exception;
|
||||
} else {
|
||||
throw new RuntimeException(exception);
|
||||
}
|
||||
}
|
||||
throw new IllegalStateException("No broker is found at any of the "
|
||||
+ jmxUrls.size() + " configured urls");
|
||||
}
|
||||
|
||||
protected synchronized void closeConnection() {
|
||||
if (connector != null) {
|
||||
|
@ -171,55 +176,61 @@ public class RemoteJMXBrokerFacade extends BrokerFacadeSupport {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds all ActiveMQ-Brokers registered on a certain JMX-Server or, if a
|
||||
* JMX-BrokerName has been set, the broker with that name.
|
||||
*
|
||||
* @param connection not <code>null</code>
|
||||
* @return Set with ObjectName-elements
|
||||
* @throws IOException
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
protected Set findBrokers(MBeanServerConnection connection) throws IOException, MalformedObjectNameException {
|
||||
ObjectName name;
|
||||
if (this.brokerName == null) {
|
||||
name = new ObjectName("org.apache.activemq:Type=Broker,*");
|
||||
} else {
|
||||
name = new ObjectName("org.apache.activemq:BrokerName=" + this.brokerName + ",Type=Broker");
|
||||
}
|
||||
/**
|
||||
* Finds all ActiveMQ-Brokers registered on a certain JMX-Server or, if a
|
||||
* JMX-BrokerName has been set, the broker with that name.
|
||||
*
|
||||
* @param connection
|
||||
* not <code>null</code>
|
||||
* @return Set with ObjectName-elements
|
||||
* @throws IOException
|
||||
* @throws MalformedObjectNameException
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
protected Set<ObjectName> findBrokers(MBeanServerConnection connection)
|
||||
throws IOException, MalformedObjectNameException {
|
||||
ObjectName name;
|
||||
if (this.brokerName == null) {
|
||||
name = new ObjectName("org.apache.activemq:Type=Broker,*");
|
||||
} else {
|
||||
name = new ObjectName("org.apache.activemq:BrokerName="
|
||||
+ this.brokerName + ",Type=Broker");
|
||||
}
|
||||
|
||||
Set brokers = connection.queryNames(name, null);
|
||||
return brokers;
|
||||
}
|
||||
Set<ObjectName> brokers = connection.queryNames(name, null);
|
||||
return brokers;
|
||||
}
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
QueueViewMBean queue = getQueue(destination.getPhysicalName());
|
||||
queue.purge();
|
||||
}
|
||||
public ManagementContext getManagementContext() {
|
||||
throw new IllegalStateException("not supported");
|
||||
}
|
||||
|
||||
public void purgeQueue(ActiveMQDestination destination) throws Exception {
|
||||
QueueViewMBean queue = getQueue(destination.getPhysicalName());
|
||||
queue.purge();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected <T> Collection<T> getManagedObjects(ObjectName[] names,
|
||||
Class<T> type) {
|
||||
MBeanServerConnection connection;
|
||||
try {
|
||||
connection = getMBeanServerConnection();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
public ManagementContext getManagementContext() {
|
||||
throw new IllegalStateException("not supported");
|
||||
}
|
||||
|
||||
protected Collection getManagedObjects(ObjectName[] names, Class type) {
|
||||
MBeanServerConnection connection;
|
||||
try {
|
||||
connection = getConnection();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
List answer = new ArrayList();
|
||||
if (connection != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
Object value = MBeanServerInvocationHandler.newProxyInstance(connection, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
List<T> answer = new ArrayList<T>();
|
||||
if (connection != null) {
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
ObjectName name = names[i];
|
||||
T value = (T) MBeanServerInvocationHandler.newProxyInstance(
|
||||
connection, name, type, true);
|
||||
if (value != null) {
|
||||
answer.add(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
return answer;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,8 +56,6 @@ import org.apache.camel.impl.DefaultCamelContext;
|
|||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import sun.util.logging.resources.logging;
|
||||
|
||||
/**
|
||||
* Represents a messaging client used from inside a web container typically
|
||||
* stored inside a HttpSession TODO controls to prevent DOS attacks with users
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
|
||||
/**
|
||||
* Base class for configurations.
|
||||
*
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public abstract class AbstractConfiguration implements WebConsoleConfiguration {
|
||||
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getJmxPassword() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Collection<JMXServiceURL> getJmxUrls() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getJmxUser() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the ActiveMQ-ConnectionFactory.
|
||||
*
|
||||
* @param jmsUrl
|
||||
* not <code>null</code>
|
||||
* @param jmsUser
|
||||
* <code>null</code> if no authentication
|
||||
* @param jmsPassword
|
||||
* <code>null</code> is ok
|
||||
* @return not <code>null</code>
|
||||
*/
|
||||
protected ConnectionFactory makeConnectionFactory(String jmsUrl, String jmsUser,
|
||||
String jmsPassword) {
|
||||
if (jmsUser != null && jmsUser.length() > 0)
|
||||
return new ActiveMQConnectionFactory(jmsUser, jmsPassword, jmsUrl);
|
||||
else
|
||||
return new ActiveMQConnectionFactory(jmsUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Splits the JMX-Url string into a series of JMSServiceURLs.
|
||||
*
|
||||
* @param jmxUrls
|
||||
* the JMX-url, multiple URLs are separated by commas.
|
||||
* @return not <code>null</code>, contains at least one element.
|
||||
*/
|
||||
protected Collection<JMXServiceURL> makeJmxUrls(String jmxUrls) {
|
||||
String[] urls = jmxUrls.split(",");
|
||||
if (urls == null || urls.length == 0) {
|
||||
urls = new String[] { jmxUrls };
|
||||
}
|
||||
|
||||
try {
|
||||
Collection<JMXServiceURL> result = new ArrayList<JMXServiceURL>(
|
||||
jmxUrls.length());
|
||||
for (String url : urls) {
|
||||
result.add(new JMXServiceURL(url));
|
||||
}
|
||||
return result;
|
||||
} catch (MalformedURLException e) {
|
||||
throw new IllegalArgumentException("Invalid JMX-url", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NameNotFoundException;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
/**
|
||||
* Configuration based on JNDI values.
|
||||
*
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public class JNDIConfiguration extends AbstractConfiguration {
|
||||
|
||||
private static final String JNDI_JMS_CONNECTION_FACTORY = "java:comp/env/jms/connectionFactory";
|
||||
private static final String JNDI_JMS_URL = "java:comp/env/jms/url";
|
||||
private static final String JNDI_JMS_USER = "java:comp/env/jms/user";
|
||||
private static final String JNDI_JMS_PASSWORD = "java:comp/env/jms/password";
|
||||
|
||||
private static final String JNDI_JMX_URL = "java:comp/env/jmx/url";
|
||||
private static final String JNDI_JMX_USER = "java:comp/env/jmx/user";
|
||||
private static final String JNDI_JMX_PASSWORD = "java:comp/env/jmx/password";
|
||||
|
||||
private InitialContext context;
|
||||
|
||||
public JNDIConfiguration() throws NamingException {
|
||||
this.context = new InitialContext();
|
||||
}
|
||||
|
||||
public JNDIConfiguration(InitialContext context) {
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
try {
|
||||
ConnectionFactory connectionFactory = (ConnectionFactory) this.context
|
||||
.lookup(JNDI_JMS_CONNECTION_FACTORY);
|
||||
return connectionFactory;
|
||||
} catch (NameNotFoundException e) {
|
||||
// try to find an url
|
||||
} catch (NamingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
String jmsUrl = (String) this.context.lookup(JNDI_JMS_URL);
|
||||
if (jmsUrl == null) {
|
||||
throw new IllegalArgumentException(
|
||||
"A JMS-url must be specified (system property "
|
||||
+ JNDI_JMS_URL);
|
||||
}
|
||||
|
||||
String jmsUser = getJndiString(JNDI_JMS_USER);
|
||||
String jmsPassword = getJndiString(JNDI_JMS_PASSWORD);
|
||||
return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword);
|
||||
} catch (NameNotFoundException e) {
|
||||
throw new IllegalArgumentException(
|
||||
"Neither a ConnectionFactory nor a JMS-url were specified");
|
||||
} catch (NamingException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected String getJndiString(String name) {
|
||||
try {
|
||||
return (String) this.context.lookup(name);
|
||||
} catch (NamingException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<JMXServiceURL> getJmxUrls() {
|
||||
String jmxUrls = getJndiString(JNDI_JMX_URL);
|
||||
return makeJmxUrls(jmxUrls);
|
||||
}
|
||||
|
||||
public String getJmxPassword() {
|
||||
return getJndiString(JNDI_JMX_USER);
|
||||
}
|
||||
|
||||
public String getJmxUser() {
|
||||
return getJndiString(JNDI_JMX_PASSWORD);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
|
||||
/**
|
||||
* Configuration based on system-properties.
|
||||
*
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public class SystemPropertiesConfiguration extends AbstractConfiguration {
|
||||
|
||||
private static final String PROPERTY_JMS_URL = "webconsole.jms.url";
|
||||
private static final String PROPERTY_JMS_USER = "webconsole.jms.user";
|
||||
private static final String PROPERTY_JMS_PASSWORD = "webconsole.jms.password";
|
||||
|
||||
private static final String PROPERTY_JMX_URL = "webconsole.jmx.url";
|
||||
private static final String PROPERTY_JMX_USER = "webconsole.jmx.user";
|
||||
private static final String PROPERTY_JMX_PASSWORD = "webconsole.jmx.password";
|
||||
|
||||
public ConnectionFactory getConnectionFactory() {
|
||||
String jmsUrl = System.getProperty(PROPERTY_JMS_URL);
|
||||
if (jmsUrl == null)
|
||||
throw new IllegalArgumentException(
|
||||
"A JMS-url must be specified (system property "
|
||||
+ PROPERTY_JMS_URL);
|
||||
|
||||
String jmsUser = System.getProperty(PROPERTY_JMS_USER);
|
||||
String jmsPassword = System.getProperty(PROPERTY_JMS_PASSWORD);
|
||||
return makeConnectionFactory(jmsUrl, jmsUser, jmsPassword);
|
||||
}
|
||||
|
||||
public Collection<JMXServiceURL> getJmxUrls() {
|
||||
String jmxUrls = System.getProperty(PROPERTY_JMX_URL);
|
||||
return makeJmxUrls(jmxUrls);
|
||||
}
|
||||
|
||||
public String getJmxPassword() {
|
||||
return System.getProperty(PROPERTY_JMX_USER);
|
||||
}
|
||||
|
||||
public String getJmxUser() {
|
||||
return System.getProperty(PROPERTY_JMX_PASSWORD);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.config;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.jms.ConnectionFactory;
|
||||
import javax.management.remote.JMXServiceURL;
|
||||
|
||||
/**
|
||||
* The configuration used for the web console.
|
||||
*
|
||||
* @version $Revision: $
|
||||
*/
|
||||
public interface WebConsoleConfiguration {
|
||||
|
||||
/**
|
||||
* The connection factory to use for sending/receiving messages.
|
||||
*
|
||||
* @return not <code>null</code>
|
||||
*/
|
||||
ConnectionFactory getConnectionFactory();
|
||||
|
||||
/**
|
||||
* The URL to the JMX connectors of the broker. The names of any failover
|
||||
* (master-slave configuration) must also be specified.
|
||||
*
|
||||
* @return not <code>null</code>, must contain at least one entry
|
||||
*/
|
||||
Collection<JMXServiceURL> getJmxUrls();
|
||||
|
||||
/**
|
||||
* The user that is used in case of authenticated JMX connections. The user
|
||||
* must be the same for all the brokers.
|
||||
*
|
||||
* @return <code>null</code> if no authentication should be used.
|
||||
*/
|
||||
String getJmxUser();
|
||||
|
||||
/**
|
||||
* Password for the JMX-user.
|
||||
*
|
||||
* @see #getJmxUser()
|
||||
* @return <code>null</code> if no authentication
|
||||
*/
|
||||
String getJmxPassword();
|
||||
|
||||
}
|
|
@ -40,5 +40,7 @@
|
|||
|
||||
<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"/>
|
||||
<bean id="queueConsumerQuery" class="org.apache.activemq.web.QueueConsumerQuery" autowire="constructor" singleton="false"/>
|
||||
<bean id="connectionQuery" class="org.apache.activemq.web.ConnectionQuery" autowire="constructor" singleton="false"/>
|
||||
|
||||
</beans>
|
||||
|
|
Loading…
Reference in New Issue