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

Spring Boot测试中使用嵌入式ActiveMQ Artemis服务器创建会话工厂失败的问题咨询

Spring Boot测试中使用嵌入式ActiveMQ Artemis服务器创建会话工厂失败的问题咨询

你好,我在Spring Boot项目里尝试访问测试用的嵌入式ActiveMQ Artemis服务器时,碰到了jakarta.jms.JMSException: Failed to create session factory的错误,下面是我的配置细节和问题情况,希望能得到大家的帮助:

错误信息

jakarta.jms.JMSException: Failed to create session factory

ConnectionFactory Bean配置

@Bean
public ConnectionFactory connectionFactory() throws JMSException {
    return new ActiveMQConnectionFactory("vm://localhost");
}

测试代码

@SpringBootTest
@ContextConfiguration(classes = {JmsConfig.class, JmsListenerTest.TestConfig.class})
@EnableAutoConfiguration
public class JmsListenerTest {

    @Configuration
    static class TestConfig {

        @Bean
        public ConnectionFactory connectionFactory() throws JMSException {
            return new ActiveMQConnectionFactory("vm://localhost");
        }
    }

    @Autowired
    private JmsTemplate jmsTemplate;

    @SpyBean
    private NotifierMessageListener listener;

    @Test
    public void receive()  {
        final var message = new NacqMessage("s2", "receive test");
        jmsTemplate.send(NotifierMessageListener.MAILBOX_JSON, s -> s.createObjectMessage(message)); // 此处抛出Failed to create session factory错误
        // ... 其余测试代码省略
    }
}

相关Gradle依赖

implementation 'org.springframework.boot:spring-boot-starter-artemis'
implementation 'org.springframework:spring-jms'
testImplementation 'org.apache.activemq:artemis-jakarta-server:2.32.0' // 不确定是否需要这个依赖

问题补充说明

  • 这个错误只在使用嵌入式服务器时出现,切换到非嵌入式服务器时功能完全正常。
  • 我已经查阅了官方文档里关于在Artemis上使用ActiveMQConnectionFactory的内容,但没有找到足够的嵌入式服务器配置指导。

想请教各位,这种场景下还需要添加哪些额外配置才能解决这个会话工厂创建失败的问题?

备注:内容来源于stack exchange,提问作者MiguelSlv

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.04.20 07:50:28