在 Spring Boot 3 中使用 OpenWire 协议嵌入的 ActiveMQ Artemis

问题描述 投票:0回答:1

我正在尝试在 Spring Boot 3 应用程序中使用嵌入式 ActiveMQ Artemis 代理并激活 OpenWire 协议。

这应该可以通过像

tcp://0.0.0.0:616161?protocols=CORE,OPENWIRE
这样的接受者实现,正如它所说的here

我将这些添加到依赖项中以使用 ActiveMQ Artemis 代理。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-artemis</artifactId>
</dependency>
<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-jakarta-server</artifactId>
</dependency>

并使用 Spring Boot 中的此 BOM

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-dependencies</artifactId>
    <version>3.2.1</version>
    <scope>import</scope>
    <type>pom</type>
</dependency>

但是当我启动应用程序时,会记录以下内容:

AMQ222203: Classpath lacks a protocol-manager for protocol OPENWIRE, Protocol being ignored on acceptor TransportConfiguration(name=artemis, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyAcceptorFactory) ?scheme=tcp&port=61616&host=0-0-0-0&protocols=CORE,AMQP,OPENWIRE

为了启用

amqp
,我添加了依赖项:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-amqp-protocol</artifactId>
</dependency>

当我对 OpenWire 执行相同操作时(Spring 也没有提供此依赖项的版本):

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>artemis-openwire-protocol</artifactId>
    <version>2.31.2</version>
</dependency>

服务器启动因以下错误而崩溃:

Caused by: java.lang.ClassNotFoundException: javax.jms.InvalidClientIDException
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
    ... 49 common frames omitted

我下载了 ActiveMQ Artemis 捆绑包并使用相同的配置启动了服务器,并且它从 OpenWire 支持开始。我查看了捆绑服务器的

lib
文件夹,还包含一个
artemis-openwire-protocol
jar。

<parent>
    <artifactId>artemis-protocols</artifactId>
    <groupId>org.apache.activemq</groupId>
    <version>2.31.2</version>
</parent>
<artifactId>artemis-openwire-protocol</artifactId>

独立的 ActiveMQ Artemis 代理能够接受 OpenWire 客户端。我需要做什么才能使用嵌入式 ActiveMQ Artemis 代理启用它?有什么提示吗?

spring-boot jms activemq-artemis
1个回答
1
投票

简而言之,目前无法使用 ActiveMQ Artemis Jakarta 代理支持任何类型的 OpenWire 客户端。

问题是您使用的

artemis-openwire-protocol
依赖项取决于
org.apache.activemq:activemq-client:5.18.3
,它包含实际的 OpenWire 协议实现以及 OpenWire JMS 客户端实现。此依赖项使用并实现
javax
命名空间中的类,这些类与 Spring Boot 3.x(使用
jakarta
命名空间)不兼容。因为
artemis-openwire-protocol
中的代码本身也引用了
javax
中的类。

最后,值得注意的是,使用 OpenWire + Jakarta 的代理时,使用

javax
命名空间的现有 OpenWire JMS 客户端可能会中断。

如果您确实需要使用使用

javax
命名空间的 JMS 应用程序,那么我建议您将这些应用程序中的 OpenWire JMS 客户端 jar 替换为 ActiveMQ Artemis 中的核心 JMS 客户端 jar(即
org.apache.activemq:artemis-jms-client
)。如果您的 JMS 应用程序编写正确(即它们不使用任何实现对象),那么它应该是一个直接的切换。只需更换罐子并更新您的
jndi.properties
文件即可。核心 JMS 客户端使用与 JMS 不紧密耦合的核心协议,因此您可以使用这两个命名空间混合和匹配客户端和代理。

© www.soinside.com 2019 - 2024. All rights reserved.