title: Spring Boot: Reading spring.jms.jndi-name property from application.properties file using a Java Bean class
body: <p>I am using <strong>JNDI lookup</strong> for the getting the connection object for <strong>Websphere MQ</strong> Broker on tomcat server. I am using <strong>JmsTemplate</strong> for sending the messages to the Queue on WMQ Broker and trying to avoid the Spring Xml based configuration and for that reason i have configured the Spring boot's application.properties file to specify the <strong>JNDI look</strong> up name.below is the property from application.properties file.</p>
  
  <pre><code>spring.jms.jndi-name= java:comp/env/XXXX
  </code></pre>
  
  <p>i am using a Spring bean to define the JmsTemplate and below is the code for it.</p>
  
  <pre><code>@Configuration
  public class JmsMessageTemplateBean {
  
      //@Value("${spring.jms.jndi-name}")
      //private ConnectionFactory connectionFactory;
  
      @Bean
      public JmsTemplate jmsTemplate() throws Exception{
          JmsTemplate jmsMessagingTemplate = new JmsTemplate();
          jmsMessagingTemplate.setDefaultDestinationName("Some Queue");
          jmsMessagingTemplate.setConnectionFactory(connectionFactory);
          return jmsMessagingTemplate;
      }
  }
  </code></pre>
  
  <p>i have a couple of questions:</p>
  
  <p>1.How to read the JNDI property from application.properties file and set the Connection object to Jms Template in the above bean.</p>
  
  <p>2.I have observed that the connection object from the <strong>JNDI lookup</strong> is <code>MQQueueConnectionFactory</code> and from what i have researched <code>JmsTemplate</code> supports <code>javax.jms.ConnectionFactory</code> object. is there a way to convert the <code>MQQueueConnectionfactory</code> object to <code>javax.jms.Connectionfactory</code>.</p>
  
  <p>Appreciate your answers.</p>