I've been struggling lately with the spring-boot-artemis-starter
.
My understanding of its Spring Boot support was the following:
- set
spring.artemis.mode=embedded
and, like Tomcat, Spring Boot will instantiate a broker reachable through TCP (server mode). The following command should be successful:nc -zv localhost 61616
- set
spring.artmis.mode=native
and Spring Boot will only configure the jms template according to thespring.artemis.*
properties (client mode).
The client mode works just fine with a standalone ActiveMQ Artemis server on my machine. Unfortunately, I could never manage to reach the TCP port in server mode.
I would be grateful if somebody confirms my understanding of the embedded mode.
After some digging I noted that the implementation provided out of the box by the spring-boot-starter-artemis
uses org.apache.activemq.artemis.core.remoting.impl.invm.InVMAcceptorFactory
acceptor. I'm wondering if that's not the root cause (again I'm by no means an expert).
But it appears that there is a way to customize artemis configuration.
Therefore I tried the following configuration without any luck:
@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");
}
};
}
}