Spring Boot - start ActiveMQ Web Console on startup

流过昼夜 提交于 2020-02-20 05:39:07

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/44108318/spring-boot-start-activemq-web-console-on-startup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!