小编lou*_*eye的帖子

Spring启动Artemis嵌入式代理行为

大家早,

我最近一直在与spring-boot-artemis-starter挣扎.我对它的spring-boot支持的理解如下:

  • 设置spring.artemis.mode=embedded,和tomcat一样,spring-boot将实现通过tcp(服务器模式)可访问的代理.以下命令应该成功:nc -zv localhost 61616
  • set spring.artmis.mode=native和spring-boot只会根据spring.artemis.*属性(客户端模式)配置jms模板.

客户端模式可以在我的机器上使用独立的artemis服务器.不幸的是,我无法在服务器模式下到达tcp端口.

如果有人确认我对嵌入式模式的理解,我将不胜感激.

感谢您的旅行帮助

经过一番挖掘后,我注意到spring-boot-starter-artemis开箱即用的实现使用了org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactoryacceptor.我想知道这不是根本原因(我再也不是专家).但似乎有一种方法可以自定义artemis配置.因此我尝试了以下配置而没有任何运气:

@SpringBootApplication
public class MyBroker {

    public static void main(String[] args) throws Exception {
        SpringApplication.run(MyBroker.class, args);
    }

    @Autowired
    private ArtemisProperties artemisProperties;

    @Bean
    public ArtemisConfigurationCustomizer artemisConfigurationCustomizer() {
        return configuration -> {
            try {
               configuration.addAcceptorConfiguration("netty", "tcp://localhost:" + artemisProperties.getPort());
            } catch (Exception e) {
                throw new RuntimeException("Failed to add netty transport acceptor to artemis instance");
            }
        };
    }

}
Run Code Online (Sandbox Code Playgroud)

broker spring-boot activemq-artemis

8
推荐指数
2
解决办法
5290
查看次数

标签 统计

activemq-artemis ×1

broker ×1

spring-boot ×1