【发布时间】:2017-02-08 23:54:24
【问题描述】:
早上好,
我最近一直在努力使用 spring-boot-artemis-starter。 我对其 spring-boot 支持的理解如下:
- 设置
spring.artemis.mode=embedded和tomcat 一样,spring-boot 将实例化一个可通过tcp(服务器模式)访问的代理。以下命令应该成功:nc -zv localhost 61616 - 设置
spring.artmis.mode=native,spring-boot只会根据spring.artemis.*属性(客户端模式)配置jms模板。
客户端模式与我机器上的独立 artemis 服务器一起工作得很好。 不幸的是,我无法在服务器模式下访问 tcp 端口。
如果有人确认我对嵌入式模式的理解,我将不胜感激。
感谢您的游览帮助
经过一番挖掘,我注意到 spring-boot-starter-artemis 提供的开箱即用的实现使用org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory 接受器。我想知道这是否不是根本原因(同样我绝不是专家)。
但似乎有一种方法可以自定义 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");
}
};
}
}
【问题讨论】:
标签: spring-boot broker activemq-artemis