title: JMS not starting in Spring Boot application
body: <p>I developed a spring boot application which send and listen message in Activemq using JMS, but while running application, JMS is not getting started by spring boot  </p>
  
  <p>This is mainclass,  Application.java</p>
  
  <pre><code>@SpringBootApplication
  @EnableJms
  public class Main {
      public static void main(String[] args) {
          SpringApplication.run(Main.class, args);
      }
  }
  </code></pre>
  
  <p>Configuration class: Config.java </p>
  
  <pre><code>@Configuration
  public class Config {
  
      @Bean
      public Queue queue() {
          return new ActiveMQQueue("inmemory.queue");
      }
  
      @Bean
      public JmsTemplate jmsTemplate() {
          return new JmsTemplate(activeMQConnectionFactory());
      }
  }
  </code></pre>
  
  <p>Listener class is used to listen to the queue: Listener.java</p>
  
  <pre><code>@Component
  public class Listener {
  
      @JmsListener(destination = "inmemory.queue")
      public void listener(String message) {
          System.out.println("message received" + message);
      }
  }
  </code></pre>
  
  <p>Producer class is used to send message to queue from controller: Producer.java</p>
  
  <pre><code>@RestController
  public class Producer {
  
      @Autowired
      Queue queue;
  
      @Autowired
      JmsTemplate jmstemplate;
  
      @RequestMapping(method = RequestMethod.GET, path = "/test3/{message}")
      public String test3(@PathVariable String message) {
          jmstemplate.convertAndSend(queue, message);
          return "teste3" + message;
      }
  }
  </code></pre>
  
  <p>application.properties</p>
  
  <pre><code>spring.activemq.in-memory=true
  spring.activemq.pool.enabled=false
  server.port=8081
  </code></pre>
  
  <p>pom.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;project&gt;
     &lt;parent&gt;
        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;
        &lt;version&gt;2.1.6.RELEASE&lt;/version&gt;
     &lt;/parent&gt;
     &lt;dependencies&gt;
        &lt;dependency&gt;
           &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
           &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
           &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;
           &lt;artifactId&gt;spring-boot-starter-activemq&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
           &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
           &lt;artifactId&gt;activemq-broker&lt;/artifactId&gt;
        &lt;/dependency&gt;
        &lt;dependency&gt;
           &lt;groupId&gt;org.springframework&lt;/groupId&gt;
           &lt;artifactId&gt;spring-jms&lt;/artifactId&gt;
           &lt;version&gt;5.1.4.RELEASE&lt;/version&gt;
        &lt;/dependency&gt;
     &lt;/dependencies&gt;
  &lt;/project&gt;
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/FFY7u.jpg" rel="nofollow noreferrer">This is a screenshot of application starting without starting JMS</a></p>