You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

spring-boot-starter-artemis配置OpenWire协议报错及默认协议咨询

ActiveMQ Artemis OpenWire协议配置与问题解答

一、客户端配置OpenWire协议的步骤

spring-boot-starter-artemis默认自带Artemis原生CORE协议的客户端,要切换到OpenWire,需调整依赖和配置:

  1. 替换客户端依赖
    在pom.xml中排除默认的artemis-jms-client,引入OpenWire对应的activemq-client:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-artemis</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.apache.activemq</groupId>
                <artifactId>artemis-jms-client</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-client</artifactId>
    </dependency>
    
  2. 修改Spring Boot连接配置
    在application.properties或application.yml中指定OpenWire的连接信息和连接工厂类:

    spring.artemis.mode=native
    spring.artemis.broker-url=tcp://localhost:61616
    # 指定OpenWire专属的连接工厂
    spring.jms.connection-factory-class=org.apache.activemq.ActiveMQConnectionFactory
    

    也可以用Java代码自定义连接工厂:

    @Bean
    public ConnectionFactory connectionFactory() {
        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
        factory.setBrokerURL("tcp://localhost:61616");
        // 按需配置用户名、密码等参数
        return factory;
    }
    

二、默认通信协议说明

spring-boot-starter-artemis默认使用ActiveMQ Artemis原生CORE协议,该协议是Artemis专属优化的协议,性能优于OpenWire,但仅能与Artemis Broker通信,不兼容传统ActiveMQ的OpenWire客户端。

三、确认实际使用的协议的方法

  1. Artemis管理控制台查看
    登录控制台(默认地址http://localhost:8161,默认账号密码admin/admin),左侧菜单选择Connections,在连接列表的Protocol列直接显示当前连接使用的协议类型(如CORE、OPENWIRE、AMQP等)。

  2. Broker日志查看
    修改Broker的logging.properties文件,添加DEBUG级别的日志配置:

    logger.org.apache.activemq.artemis.core.server.acceptors.level=DEBUG
    

    重启Broker后,客户端连接时日志会输出类似Accepting connection from /127.0.0.1:54321 protocol=OPENWIRE的信息,明确标注协议类型。

  3. 客户端代码验证
    若使用OpenWire的ActiveMQConnectionFactory,可通过代码打印连接细节确认:

    Connection connection = connectionFactory.createConnection();
    ActiveMQConnection activeMQConn = (ActiveMQConnection) connection;
    System.out.println("当前连接使用协议:OPENWIRE");
    // 也可打印传输层信息验证
    System.out.println("远程地址:" + activeMQConn.getTransport().getRemoteAddress());
    

关于你遇到的超时错误

你出现的AMQ219013: Timed out waiting to receive cluster topology错误,原因是客户端仍在使用默认的CORE协议客户端连接,但Broker的Acceptor仅开启了OPENWIRE协议,两者不兼容导致连接失败。按照上述步骤切换到OpenWire客户端后,该问题即可解决。

内容的提问来源于stack exchange,提问作者magos

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.11 11:36:01