Spring Boot-启动时启动ActiveMQ Web控制台 [英] Spring Boot - start ActiveMQ Web Console on startup

查看:176
本文介绍了Spring Boot-启动时启动ActiveMQ Web控制台的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Spring Boot应用程序,它可以自动启动ActiveMQ代理(vm:// localhost):它可以工作,我可以成功发送和接收消息。

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

我希望Spring Boot也启动 ActiveMQ Web控制台,例如 http:// localhost:8161 / admin (与H2数据库控制台非常相似)。

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).

问题:如何使Spring Boot应用启动ActiveMQ Web控制台?

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

奖励积分:仅适用于特定的春季@个人资料?

Bonus Points: for a specific Spring @profile only?

预先感谢

注意:我已经查看了如何在ActiveMq嵌入式代理上启用Web控制台,但这需要使用我不想/不能使用的hawtio。

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.

推荐答案

Web控制台是一个Web应用程序,可以在任何servlet容器(例如Tomcat)中下载并启动。

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

以下是一些步骤。

在activemq.xml中启用ActiveMQ以供JMX使用。也就是说-在Broker标签中启用它:< broker useJmx = true ..和

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

确保 createConnector true

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

从Maven下载.war。最好使用与代理相同的版本。

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/

然后设置以下JVM属性(JAVA_OPTS)。请注意,如果更改了URL和端口,则它们可能会有所不同。

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

如果您没有Tomcat(或servlet容器),并且希望使用 java -jar ..运行Spring引导应用程序-您可以

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.

使用此应用的以下示例: https://github.com/jsimone/webapp-runner

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

由于未与Webapp捆绑在一起,因此不得不添加jstl jar -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 

管理员控制台将托管在localhost的端口8085上。这只是一个启动器。您可能需要添加故障转移,安全性等。YMMV

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

这篇关于Spring Boot-启动时启动ActiveMQ Web控制台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆