I have two spring-boot applications. in receiver-application's Application.java I have:
@Bean
public JmsListenerContainerFactory<?> myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
configurer.configure(factory, connectionFactory);
return factory;
}
and in Receiver.java ...
@JmsListener(destination = "myQueue", containerFactory = "myFactory")
public void receiveMessage(String tradeString) throws JSONException, IOException {
tradeImpl = new ObjectMapper().readValue(tradeString, TradeImpl.class);
}
In sender-application I simply use:
public void send(trade) {
String queueName = "myQueue";
String tradeString = new ObjectMapper().writeValueAsString(trade);
jmsTemplate.convertAndSend(queueName, tradeString);
}
So I'm just sending the message to the queue name specified in receiver-application. I get the following in the logs
Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099>/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException:
I have read the following post and didn't find it very encouraging:
Spring boot - sharing embedded JMS broker with separate service
It concludes with:
But As I mentioned I didn't make this working before and not sure if it is possible. Didn't find in Spring Boot docs explicit message it doesn't work in this combination.
I suspect the idea behind embedded Spring Boot JMS broker is to allow local in memory integration testing only, not to expose embedded JMS brokers to the outside world.
Does anybody know if what I want to do is indeed possible? And if not, are there any suggestions on how I can achieve messaging between to spring-boot apps using embedded brokers?