title: How to send Jms message from one spring-boot application to another when both apps use embedded activemq
body: <p>I have two spring-boot applications. in receiver-application's Application.java I have:</p>
  <pre><code>@Bean
  public JmsListenerContainerFactory&lt;?&gt; myFactory(ConnectionFactory connectionFactory, DefaultJmsListenerContainerFactoryConfigurer configurer) {
      DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
      configurer.configure(factory, connectionFactory);
      return factory;
  }
  </code></pre>
  <p>and in Receiver.java  ...</p>
  <pre><code>@JmsListener(destination = &quot;myQueue&quot;, containerFactory = &quot;myFactory&quot;)
  public void receiveMessage(String tradeString) throws JSONException, IOException {
      tradeImpl = new ObjectMapper().readValue(tradeString, TradeImpl.class);
  }
  </code></pre>
  <p>In sender-application I simply use:</p>
  <pre><code>public void send(trade) {
     String queueName = &quot;myQueue&quot;;
     String tradeString = new ObjectMapper().writeValueAsString(trade);
     jmsTemplate.convertAndSend(queueName, tradeString);
  }
  </code></pre>
  <p>So I'm just sending the message to the queue name specified in receiver-application.
  I get the following in the logs</p>
  <blockquote>
  <p>Failed to start JMX connector Cannot bind to URL [rmi://localhost:1099&gt;/jmxrmi]: javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is java.rmi.AlreadyBoundException:</p>
  </blockquote>
  <p>I have read the following post and didn't find it very encouraging:</p>
  <p><a href="https://stackoverflow.com/questions/34607596/spring-boot-sharing-embedded-jms-broker-with-separate-service">Spring boot - sharing embedded JMS broker with separate service</a></p>
  <p>It concludes with:</p>
  <blockquote>
  <p>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.</p>
  <p>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.</p>
  </blockquote>
  <p>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?</p>