This is an automated email from the ASF dual-hosted git repository.
jbonofre pushed a commit to branch activemq-6.2.x
in repository https://gitbox.apache.org/repos/asf/activemq.git
The following commit(s) were added to refs/heads/activemq-6.2.x by this push:
new 1dabafb8ac fix(webconsole): the webconsole now redirect to the
slave.jsp when required (slave broker with startAsync="true") [6.2.x] (#1934)
1dabafb8ac is described below
commit 1dabafb8ac124d7b6421ef935e59b42d028cc970
Author: JB Onofré <[email protected]>
AuthorDate: Fri Apr 17 15:44:17 2026 +0200
fix(webconsole): the webconsole now redirect to the slave.jsp when required
(slave broker with startAsync="true") [6.2.x] (#1934)
* fix(webconsole): the webconsole now redirect to the slave.jsp when
required (slave broker with startAsync="true")
* fix(assembly): add id="broker" to sample configs so jetty.xml depends-on
resolves
The BrokerXmlConfigStartTest loads all activemq-*.xml sample configs
which import jetty.xml. Since jetty.xml now has depends-on="broker" on
the invokeStart bean, the sample configs need a matching bean id.
---
.../web/filter/ApplicationContextFilter.java | 30 ++++++++++++----------
assembly/src/release/conf/activemq.xml | 2 +-
assembly/src/release/conf/jetty.xml | 2 +-
.../src/release/examples/conf/activemq-demo.xml | 2 +-
.../release/examples/conf/activemq-security.xml | 2 +-
.../src/release/examples/conf/activemq-stomp.xml | 2 +-
6 files changed, 22 insertions(+), 18 deletions(-)
diff --git
a/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java
b/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java
index a82e9f4a98..31bca89fb5 100644
---
a/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java
+++
b/activemq-web-console/src/main/java/org/apache/activemq/web/filter/ApplicationContextFilter.java
@@ -66,6 +66,7 @@ public class ApplicationContextFilter implements Filter {
private String applicationContextName = "applicationContext";
private String requestContextName = "requestContext";
private String requestName = "request";
+ private String slavePage = "slave.jsp";
public void init(FilterConfig config) throws ServletException {
this.servletContext = config.getServletContext();
@@ -84,19 +85,22 @@ public class ApplicationContextFilter implements Filter {
Map requestContextWrapper = createRequestContextWrapper(request);
String path = ((HttpServletRequest)request).getRequestURI();
// handle slave brokers
-// try {
-// if ( !(path.endsWith("css") || path.endsWith("png") ||
path.endsWith("ico") || path.endsWith(slavePage))
-// &&
((BrokerFacade)requestContextWrapper.get("brokerQuery")).isSlave()) {
-// ((HttpServletResponse)response).sendRedirect(slavePage);
-// return;
-// }
-// } catch (Exception e) {
-// LOG.warn(path + ", failed to access BrokerFacade: reason: " +
e.getLocalizedMessage());
-// if (LOG.isDebugEnabled()) {
-// LOG.debug(request.toString(), e);
-// }
-// throw new IOException(e);
-// }
+ try {
+ boolean isSlave = ((BrokerFacade)
requestContextWrapper.get("brokerQuery")).getBrokerAdmin().isSlave();
+ if (isSlave && !(path.endsWith("css") || path.endsWith("png") ||
path.endsWith("ico") || path.endsWith(slavePage))) {
+ ((HttpServletResponse) response).sendRedirect(slavePage);
+ return;
+ } else if (!isSlave && path.endsWith(slavePage)) {
+ ((HttpServletResponse)
response).sendRedirect(((HttpServletRequest) request).getContextPath() +
"/index.jsp");
+ return;
+ }
+ } catch (Exception e) {
+ LOG.warn(path + ", failed to access BrokerFacade: reason: " +
e.getLocalizedMessage());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug(request.toString(), e);
+ }
+ throw new IOException(e);
+ }
request.setAttribute(requestContextName, requestContextWrapper);
request.setAttribute(requestName, request);
chain.doFilter(request, response);
diff --git a/assembly/src/release/conf/activemq.xml
b/assembly/src/release/conf/activemq.xml
index 9f32bd90f5..39ba30d7ae 100644
--- a/assembly/src/release/conf/activemq.xml
+++ b/assembly/src/release/conf/activemq.xml
@@ -31,7 +31,7 @@
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
- <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="localhost" dataDirectory="${activemq.data}">
+ <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="localhost" dataDirectory="${activemq.data}" id="broker">
<destinationPolicy>
<policyMap>
diff --git a/assembly/src/release/conf/jetty.xml
b/assembly/src/release/conf/jetty.xml
index cb3d281ea3..fd000137fc 100644
--- a/assembly/src/release/conf/jetty.xml
+++ b/assembly/src/release/conf/jetty.xml
@@ -209,7 +209,7 @@
</bean>
<bean id="invokeStart"
class="org.springframework.beans.factory.config.MethodInvokingFactoryBean"
- depends-on="configureJetty, invokeConnectors">
+ depends-on="broker, configureJetty, invokeConnectors">
<property name="targetObject" ref="Server" />
<property name="targetMethod" value="start" />
</bean>
diff --git a/assembly/src/release/examples/conf/activemq-demo.xml
b/assembly/src/release/examples/conf/activemq-demo.xml
index a6954cf2f1..02d6ae1960 100644
--- a/assembly/src/release/examples/conf/activemq-demo.xml
+++ b/assembly/src/release/examples/conf/activemq-demo.xml
@@ -47,7 +47,7 @@
- Change the brokerName attribute to something unique
-->
- <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="amq-broker" useJmx="true">
+ <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="amq-broker" useJmx="true" id="broker">
<!--
Examples of destination-specific policies using destination
diff --git a/assembly/src/release/examples/conf/activemq-security.xml
b/assembly/src/release/examples/conf/activemq-security.xml
index 3d34dde557..873a9ba841 100644
--- a/assembly/src/release/examples/conf/activemq-security.xml
+++ b/assembly/src/release/examples/conf/activemq-security.xml
@@ -63,7 +63,7 @@
</bean>
-->
- <broker useJmx="true" persistent="false"
xmlns="http://activemq.apache.org/schema/core" >
+ <broker useJmx="true" persistent="false"
xmlns="http://activemq.apache.org/schema/core" id="broker">
<managementContext>
<managementContext createConnector="true">
diff --git a/assembly/src/release/examples/conf/activemq-stomp.xml
b/assembly/src/release/examples/conf/activemq-stomp.xml
index 0fe5b11c2b..d2f6fee4bf 100644
--- a/assembly/src/release/examples/conf/activemq-stomp.xml
+++ b/assembly/src/release/examples/conf/activemq-stomp.xml
@@ -44,7 +44,7 @@
<!--
The <broker> element is used to configure the ActiveMQ broker.
-->
- <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="localhost" dataDirectory="${activemq.data}">
+ <broker xmlns="http://activemq.apache.org/schema/core"
brokerName="localhost" dataDirectory="${activemq.data}" id="broker">
<!--
For better performances use VM cursor and small memory limit.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact