You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by jb...@apache.org on 2020/06/22 14:10:38 UTC

[activemq] branch activemq-5.15.x updated: AMQ-7499 add pause/resume operation of a queue in web console

This is an automated email from the ASF dual-hosted git repository.

jbonofre pushed a commit to branch activemq-5.15.x
in repository https://gitbox.apache.org/repos/asf/activemq.git


The following commit(s) were added to refs/heads/activemq-5.15.x by this push:
     new 18e8ce1  AMQ-7499 add pause/resume operation of a queue in web console
18e8ce1 is described below

commit 18e8ce18da0323809b3d5d68cb31c92ea2d14208
Author: Philipp Daniels <ph...@gmail.com>
AuthorDate: Fri Jun 19 10:47:35 2020 +0200

    AMQ-7499 add pause/resume operation of a queue in web console
    
    (cherry picked from commit 071edf522e0fb82779c01e97479f48bf48493f66)
---
 .../activemq/web/controller/PauseDestination.java  | 49 ++++++++++++++++++++++
 .../activemq/web/controller/ResumeDestination.java | 49 ++++++++++++++++++++++
 .../src/main/webapp/WEB-INF/dispatcher-servlet.xml |  2 +
 activemq-web-console/src/main/webapp/queues.jsp    | 14 +++++++
 4 files changed, 114 insertions(+)

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 0000000..fd1c089
--- /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 0000000..9009557
--- /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 513e4b9..9e36e16 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 @@
   <bean name="/moveMessage.action" class="org.apache.activemq.web.controller.MoveMessage" autowire="constructor"  scope="prototype"/>
   <bean name="/deleteJob.action" class="org.apache.activemq.web.controller.DeleteJob" autowire="constructor"  scope="prototype"/>
   <bean name="/retryMessage.action" class="org.apache.activemq.web.controller.RetryMessage" autowire="constructor" scope="prototype"/>
+  <bean name="/pauseDestination.action" class="org.apache.activemq.web.controller.PauseDestination" autowire="constructor" scope="prototype"/>
+  <bean name="/resumeDestination.action" class="org.apache.activemq.web.controller.ResumeDestination" autowire="constructor" scope="prototype"/>
 
   <!--
     - This bean resolves specific types of exception to corresponding error views.
diff --git a/activemq-web-console/src/main/webapp/queues.jsp b/activemq-web-console/src/main/webapp/queues.jsp
index 27521a6..4bd8efd 100644
--- a/activemq-web-console/src/main/webapp/queues.jsp
+++ b/activemq-web-console/src/main/webapp/queues.jsp
@@ -101,6 +101,20 @@
                     <c:param name="JMSDestination" value="${row.name}" />
                     <c:param name="JMSDestinationType" value="queue"   />
                     <c:param name="secret" value='${sessionScope["secret"]}'/></c:url>">Delete</a>
+    <c:choose>
+    <c:when test="${row.isPaused()}">
+    <a href="<c:url value="resumeDestination.action">
+                    <c:param name="JMSDestination" value="${row.name}" />
+                    <c:param name="JMSDestinationType" value="queue"   />
+                    <c:param name="secret" value='${sessionScope["secret"]}'/></c:url>">Resume</a>
+    </c:when>
+    <c:otherwise>
+    <a href="<c:url value="pauseDestination.action">
+                    <c:param name="JMSDestination" value="${row.name}" />
+                    <c:param name="JMSDestinationType" value="queue"   />
+                    <c:param name="secret" value='${sessionScope["secret"]}'/></c:url>">Pause</a>
+    </c:otherwise>
+    </c:choose>
 </td>
 </tr>