6

I have a Spring Boot app that automatically starts up an ActiveMQ broker (vm://localhost): it works, I can successfully send and receive messages.

I would like Spring Boot to also start the ActiveMQ Web Console e.g. http://localhost:8161/admin (much like it can with the H2 Database console).

Question: how do I make a Spring Boot app start the ActiveMQ Web Console?

Bonus Points: for a specific Spring @profile only?

thanks in advance

Note: I have already reviewed How to enable web console on ActiveMq embedded broker but this requires the use the hawtio which I do not want to/cannot use.

Lawrence Tierney
  • 856
  • 1
  • 12
  • 30
  • Possible duplicate of [How to enable web console on ActiveMq embedded broker](http://stackoverflow.com/questions/20211770/how-to-enable-web-console-on-activemq-embedded-broker) – pvpkiran May 22 '17 at 08:48
  • r.e. the possible duplicate: the accepted answer is to use hawt.io - I do not want to use this. – Lawrence Tierney May 22 '17 at 08:52
  • if you cannot use hawtio you have to build and embedd this artifact https://github.com/apache/activemq/tree/master/activemq-web-console as a jar and start a server as done here https://github.com/apache/activemq/blob/master/activemq-web-console/src/test/java/org/apache/activemq/web/tool/Main.java – Hassen Bennour May 22 '17 at 12:08

1 Answers1

4

The Web Console is a web app that can be downloaded and started in any servlet container such as Tomcat.

Here are some steps.

Enable ActiveMQ for JMX use in activemq.xml. That is - enable it in the broker tag: <broker useJmx="true" .. and

And make sure createConnector is true.

<managementContext>
        <managementContext createConnector="true"/>
</managementContext>

Download the .war from Maven. Better use the same version as the broker.

http://repo1.maven.org/maven2/org/apache/activemq/activemq-web-console/5.14.5/

Then setup the following JVM properties (JAVA_OPTS). Note that URL and ports may differ if you have changed them.

-Dwebconsole.type=properties 
-Dwebconsole.jms.url=tcp://localhost:61616 
-Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

If you have no Tomcat (or servlet container) and prefer to run your Spring boot apps with "java -jar .. " - you can do the same with the Web console.

Example below using this app: https://github.com/jsimone/webapp-runner

Had to add jstl jar as it wasn't bundled with webapp-runner.

java -Dwebconsole.type=properties -Dwebconsole.jms.url=tcp://localhost:61616 -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi -cp jstl-1.2.jar:webapp-runner.jar webapp.runner.launch --port 8085 activemq-web-console-5.14.5.war 

The admin console will be hosted on localhost at port 8085. This is just a starter. You may want to add fail-over, security etc etc. YMMV

Petter Nordlander
  • 22,053
  • 5
  • 50
  • 84
  • Do we need to add into activemq.xml? If yes, How we can add it. If we are using war – Rohit Deshmukh Jun 21 '19 at 07:33
  • for me this solution is not working: the web console logs say `No broker is found at any of the 1 configured urls` in the artemis server I have activated jmx with `configuration.setJMXManagementEnabled(true);` but this configuration object does not provide any way to set this `` how can i do this without using an xml file ? – aminator Feb 05 '22 at 13:35
  • This answer is for ActiveMQ Classic not Artemis – Petter Nordlander Feb 09 '22 at 09:10