From 071edf522e0fb82779c01e97479f48bf48493f66 Mon Sep 17 00:00:00 2001 From: Philipp Daniels Date: Fri, 19 Jun 2020 10:47:35 +0200 Subject: [PATCH] AMQ-7499 add pause/resume operation of a queue in web console --- .../web/controller/PauseDestination.java | 49 +++++++++++++++++++ .../web/controller/ResumeDestination.java | 49 +++++++++++++++++++ .../webapp/WEB-INF/dispatcher-servlet.xml | 2 + .../src/main/webapp/queues.jsp | 14 ++++++ 4 files changed, 114 insertions(+) create mode 100644 activemq-web-console/src/main/java/org/apache/activemq/web/controller/PauseDestination.java create mode 100644 activemq-web-console/src/main/java/org/apache/activemq/web/controller/ResumeDestination.java diff --git a/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PauseDestination.java b/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PauseDestination.java new file mode 100644 index 0000000000..fd1c0893af --- /dev/null +++ b/activemq-web-console/src/main/java/org/apache/activemq/web/controller/PauseDestination.java @@ -0,0 +1,49 @@ +/** + * 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.controller; + +import org.apache.activemq.web.BrokerFacade; +import org.apache.activemq.web.DestinationFacade; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * + */ +public class PauseDestination extends DestinationFacade implements Controller { + + public PauseDestination(BrokerFacade brokerFacade) { + super(brokerFacade); + } + + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { + pauseDestination(); + return redirectToBrowseView(); + } + + public void pauseDestination() throws Exception { + if (isQueue()) { + getQueueView().pause(); + } else { + throw new UnsupportedOperationException("Pause supported for queues only. Receieved JMSDestinationType=" + getJMSDestinationType()); + } + } +} diff --git a/activemq-web-console/src/main/java/org/apache/activemq/web/controller/ResumeDestination.java b/activemq-web-console/src/main/java/org/apache/activemq/web/controller/ResumeDestination.java new file mode 100644 index 0000000000..9009557acf --- /dev/null +++ b/activemq-web-console/src/main/java/org/apache/activemq/web/controller/ResumeDestination.java @@ -0,0 +1,49 @@ +/** + * 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.controller; + +import org.apache.activemq.web.BrokerFacade; +import org.apache.activemq.web.DestinationFacade; +import org.springframework.web.servlet.ModelAndView; +import org.springframework.web.servlet.mvc.Controller; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * + * + */ +public class ResumeDestination extends DestinationFacade implements Controller { + + public ResumeDestination(BrokerFacade brokerFacade) { + super(brokerFacade); + } + + public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception { + resumeDestination(); + return redirectToBrowseView(); + } + + public void resumeDestination() throws Exception { + if (isQueue()) { + getQueueView().resume(); + } else { + throw new UnsupportedOperationException("Resume supported for queues only. Receieved JMSDestinationType=" + getJMSDestinationType()); + } + } +} diff --git a/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml b/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml index 513e4b956f..9e36e16011 100644 --- a/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml +++ b/activemq-web-console/src/main/webapp/WEB-INF/dispatcher-servlet.xml @@ -40,6 +40,8 @@ + +