From db1e3fc9e375f6fa2692c2cc3d539af563063be7 Mon Sep 17 00:00:00 2001 From: artnaseef Date: Fri, 14 Mar 2014 19:52:03 -0700 Subject: [PATCH] AMQ-2429: Add pages listing producers for Queues and Topics. --- .../main/webapp/WEB-INF/webconsole-query.xml | 2 + .../src/main/webapp/queueProducers.jsp | 70 +++++++++++++++++++ .../src/main/webapp/queues.jsp | 2 + .../src/main/webapp/topicProducers.jsp | 70 +++++++++++++++++++ .../src/main/webapp/topics.jsp | 2 + .../org/apache/activemq/web/BrokerFacade.java | 24 ++++++- .../activemq/web/BrokerFacadeSupport.java | 23 ++++++ .../activemq/web/QueueProducerQuery.java | 45 ++++++++++++ .../activemq/web/TopicProducerQuery.java | 45 ++++++++++++ 9 files changed, 282 insertions(+), 1 deletion(-) create mode 100644 activemq-web-console/src/main/webapp/queueProducers.jsp create mode 100644 activemq-web-console/src/main/webapp/topicProducers.jsp create mode 100644 activemq-web/src/main/java/org/apache/activemq/web/QueueProducerQuery.java create mode 100644 activemq-web/src/main/java/org/apache/activemq/web/TopicProducerQuery.java diff --git a/activemq-web-console/src/main/webapp/WEB-INF/webconsole-query.xml b/activemq-web-console/src/main/webapp/WEB-INF/webconsole-query.xml index 6a1fcf6045..556d9b7fe7 100644 --- a/activemq-web-console/src/main/webapp/WEB-INF/webconsole-query.xml +++ b/activemq-web-console/src/main/webapp/WEB-INF/webconsole-query.xml @@ -21,5 +21,7 @@ + + diff --git a/activemq-web-console/src/main/webapp/queueProducers.jsp b/activemq-web-console/src/main/webapp/queueProducers.jsp new file mode 100644 index 0000000000..724a76cee2 --- /dev/null +++ b/activemq-web-console/src/main/webapp/queueProducers.jsp @@ -0,0 +1,70 @@ +<%-- + 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. +--%> + + + + +<%@include file="decorators/head.jsp" %> + + + +<%@include file="decorators/header.jsp" %> + + + +

Active Producers for

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Client ID +
+ Connection ID +
SessionIdProducerIdProducerWindowSizeDispatchAsyncBlockedBlockedTimeSentCount
+ ">
+
+ +
+<%@include file="decorators/footer.jsp" %> + + + diff --git a/activemq-web-console/src/main/webapp/queues.jsp b/activemq-web-console/src/main/webapp/queues.jsp index 8b3a2044cd..86e5772433 100644 --- a/activemq-web-console/src/main/webapp/queues.jsp +++ b/activemq-web-console/src/main/webapp/queues.jsp @@ -66,6 +66,8 @@ ">Browse ">Active Consumers
+ + ">Active Producers
diff --git a/activemq-web-console/src/main/webapp/topicProducers.jsp b/activemq-web-console/src/main/webapp/topicProducers.jsp new file mode 100644 index 0000000000..2a140773d1 --- /dev/null +++ b/activemq-web-console/src/main/webapp/topicProducers.jsp @@ -0,0 +1,70 @@ +<%-- + 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. +--%> + + + + +<%@include file="decorators/head.jsp" %> + + + +<%@include file="decorators/header.jsp" %> + + + +

Active Producers for

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Client ID +
+ Connection ID +
SessionIdProducerIdProducerWindowSizeDispatchAsyncBlockedBlockedTimeSentCount
+ ">
+
+ +
+<%@include file="decorators/footer.jsp" %> + + + diff --git a/activemq-web-console/src/main/webapp/topics.jsp b/activemq-web-console/src/main/webapp/topics.jsp index f9641807d6..d44de088b2 100644 --- a/activemq-web-console/src/main/webapp/topics.jsp +++ b/activemq-web-console/src/main/webapp/topics.jsp @@ -61,6 +61,8 @@
">Send To + + ">Active Producers
diff --git a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java index d4bf13ac08..c7e4d4a6f0 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacade.java @@ -72,6 +72,28 @@ public interface BrokerFacade { Collection getQueueConsumers(String queueName) throws Exception; + /** + * All active producers to a queue. + * + * @param queueName + * the name of the queue, not null + * @return not null + * @throws Exception + */ + Collection getQueueProducers(String queueName) + throws Exception; + + /** + * All active producers to a topic. + * + * @param queueName + * the name of the topic, not null + * @return not null + * @throws Exception + */ + Collection getTopicProducers(String queueName) + throws Exception; + /** * Active durable subscribers to topics of the broker. * @@ -209,4 +231,4 @@ public interface BrokerFacade { boolean isJobSchedulerStarted(); -} \ No newline at end of file +} diff --git a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java index babd8925f7..aa2006ad1b 100644 --- a/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java +++ b/activemq-web/src/main/java/org/apache/activemq/web/BrokerFacadeSupport.java @@ -39,6 +39,7 @@ import org.apache.activemq.broker.jmx.NetworkBridgeViewMBean; 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.ProducerViewMBean; import org.apache.activemq.broker.jmx.TopicViewMBean; import org.springframework.util.StringUtils; @@ -216,6 +217,28 @@ public abstract class BrokerFacadeSupport implements BrokerFacade { return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]), SubscriptionViewMBean.class); } + @Override + @SuppressWarnings("unchecked") + public Collection getQueueProducers(String queueName) throws Exception { + String brokerName = getBrokerName(); + queueName = StringUtils.replace(queueName, "\"", "_"); + ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName + + ",destinationType=Queue,destinationName=" + queueName + ",endpoint=Producer,*"); + Set queryResult = queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]), ProducerViewMBean.class); + } + + @Override + @SuppressWarnings("unchecked") + public Collection getTopicProducers(String topicName) throws Exception { + String brokerName = getBrokerName(); + topicName = StringUtils.replace(topicName, "\"", "_"); + ObjectName query = new ObjectName("org.apache.activemq:type=Broker,brokerName=" + brokerName + + ",destinationType=Topic,destinationName=" + topicName + ",endpoint=Producer,*"); + Set queryResult = queryNames(query, null); + return getManagedObjects(queryResult.toArray(new ObjectName[queryResult.size()]), ProducerViewMBean.class); + } + @Override @SuppressWarnings("unchecked") public Collection getConsumersOnConnection(String connectionName) throws Exception { diff --git a/activemq-web/src/main/java/org/apache/activemq/web/QueueProducerQuery.java b/activemq-web/src/main/java/org/apache/activemq/web/QueueProducerQuery.java new file mode 100644 index 0000000000..b5ca8c9dc2 --- /dev/null +++ b/activemq-web/src/main/java/org/apache/activemq/web/QueueProducerQuery.java @@ -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.ProducerViewMBean; + +/** + * Query for Queue producers. + * + * + */ +public class QueueProducerQuery extends DestinationFacade { + + public QueueProducerQuery(BrokerFacade brokerFacade) throws JMSException { + super(brokerFacade); + setJMSDestinationType("queue"); + } + + public Collection getProducers() throws Exception { + return getBrokerFacade().getQueueProducers(getJMSDestination()); + } + + public void destroy() { + // empty + } + +} diff --git a/activemq-web/src/main/java/org/apache/activemq/web/TopicProducerQuery.java b/activemq-web/src/main/java/org/apache/activemq/web/TopicProducerQuery.java new file mode 100644 index 0000000000..e645c27e5b --- /dev/null +++ b/activemq-web/src/main/java/org/apache/activemq/web/TopicProducerQuery.java @@ -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.ProducerViewMBean; + +/** + * Query for Topic producers. + * + * + */ +public class TopicProducerQuery extends DestinationFacade { + + public TopicProducerQuery(BrokerFacade brokerFacade) throws JMSException { + super(brokerFacade); + setJMSDestinationType("queue"); + } + + public Collection getProducers() throws Exception { + return getBrokerFacade().getTopicProducers(getJMSDestination()); + } + + public void destroy() { + // empty + } + +}