【问题标题】:Spring Boot Artemis Server connect Web ConsoleSpring Boot Artemis Server 连接 Web 控制台
【发布时间】:2022-02-07 07:56:41
【问题描述】:

如何将 Web 控制台连接到 Spring Boot 嵌入式 Artemis 服务器?

我主要关注这个Answer

  • tomcat 9.0.58
  • activemq-web-console-5.16.3.warwebapps 文件夹中
  • jakarta.servlet.jsp.jstl-1.2.6.jar & jakarta.servlet.jsp.jstl-api-1.2.7.jar 添加到webapps/activemq-web-console-5.16.3/WEB-INF/lib,否则控制台将无法启动
  • catalina.bat 中添加了set "JAVA_OPTS=%JAVA_OPTS% -Dwebconsole.type=properties -Dwebconsole.jms.url=tcp://localhost:61616 -Dwebconsole.jmx.url=service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi

但是现在当我访问网络控制台时 - 错误

  • 我收到Exception occurred while processing this request, check the log for more information!
  • 日志显示:IllegalStateException: No broker is found at any of the 1 configured urls

我的 Artemis 服务器在一个简约的 Spring Boot 应用程序中运行:

  • 从 VMOptions 开始:-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.rmi.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false
  • spring boot 父级:spring-boot-starter-parent:2.6.2
  • 活跃的MQ:artemis-jms-server:2.19.0
  • spring-boot-starter-web:2.6.2
  • 和以下配置类:
  @Configuration
  public class ArtemisConfig implements ArtemisConfigurationCustomizer {

    @Autowired
    private ArtemisProperties artemisProperties;

    @Override
    public void customize(org.apache.activemq.artemis.core.config.Configuration configuration) {
      try{

        configuration.setJMXManagementEnabled(true);
        configuration.setSecurityEnabled(false);
        configuration.addAcceptorConfiguration("netty", "tcp://localhost:" + artemisProperties.getPort());

      } catch (Exception e) {
        throw new RuntimeException("queue did not start");
      }
    }
  }

【问题讨论】:

    标签: spring-boot activemq-artemis


    【解决方案1】:

    您引用的the answer 唯一真正的问题是它是为 ActiveMQ“经典”而不是 ActiveMQ Artemis 编写的。 ActiveMQ Artemis 不使用activemq-web-console-5.16.3.war。它使用基于 Hawtio 2 的 Web 控制台,分为 3 个不同的战争文件:

    将这些部署到您的嵌入式 servlet 容器(例如 Tomcat、Jetty 等)。我认为您不需要设置任何系统属性,但在发布过程中,我们实际上删除了任何 SLF4J 和 Log4j jar 文件,因此如果您的环境尚未提供它们,您可能需要重新添加它们。我们删除这些 jars 是因为我们实际上在独立代理的主 lib 目录中运送 SLF4J,而且我们实际上并不需要 Log4j(因为 ActiveMQ Artemis 使用 JBoss Logging)所以删除它更安全(尤其是在所有最近的 Log4j CVE)。有关详细信息,请参阅ARTEMIS-3612

    在浏览器中运行的 Web 控制台应用程序通过 Jolokia 与代理通信,Jolokia 是一个 HTTP-JMX 桥。 Jolokia 是 Hawtio 2 基础设施的一部分,包含在上述战争文件中。如果战争文件与嵌入了 ActiveMQ Artemis 的 Spring Boot 应用程序托管在同一个 JVM 中,那么您只需将 Web 控制台应用程序指向您用于控制台本身的同一服务器和端口。如果 Web 控制台与 Spring Boot 应用程序分开托管,那么您应该 install Jolokia 然后将 Web 控制台指向它。

    【讨论】:

    • 感谢您的快速响应。
    • 我已经在这里看到了你的答案:stackoverflow.com/a/69105578/8574536。对我来说不幸的是,缺少一块拼图。当我在 tomcat 中启动这个控制台时,我怎样才能将这个东西连接到 artemis 服务器?屏幕上有一个连接按钮,但我只能选择 http/https 模式,但这不是由 artemis 服务器提供的。这个控制台是否期望 artemis 服务器在同一个 tomcat 上运行?因为这对我来说不是这样。 Artemis 服务器嵌入在一个单独的 Spring Boot 应用程序中运行。
    • 另外,我必须将slf4j-api-1.7.33.jarlog4j-over-slf4j-1.7.25.jar 这两个jar 添加到所有这3 个war 文件的WEB-INF/lib 文件夹中。
    • 再次感谢您的快速响应。你说everything should be in the same JVM,但这正是我的意思,是NOT in the same JVM。控制台部署在某个 tomcat 上,而 artemis 服务器嵌入在单独的 spring boot 应用程序中运行(具有自己的嵌入式 tomcat)。
    • 我更新了我的答案。希望最终澄清!
    猜你喜欢
    • 2021-03-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多