title: Can Single JMSTemplate be shared in multiple producers?
body: <p>I want to share the single instance of JMSTemplate for multiple producers connecting to ActiveMQ broker. Sample config:</p>
  
  <pre><code>&lt;bean id="ProducerJmsTemplate" class="org.springframework.jms.core.JmsTemplate"&gt;
   &lt;property name="connectionFactory"&gt;
       &lt;ref bean="gloProducerJmsFactory" /&gt;
   &lt;/property&gt;
  &lt;/bean&gt;
  
  &lt;bean id="pnlMessageProducer1" class="glo.business.core.FAGSCompletionMessage1"
   p:jmsTemplate-ref="ProducerJmsTemplate"
   p:messageDestination-ref="topic_loadGearTb1"
  &lt;/bean&gt;
  
  &lt;bean id="pnlMessageProducer2" class="glo.business.core.FAGSCompletionMessage2"
  p:jmsTemplate-ref="ProducerJmsTemplate" 
  p:messageDestination-ref="topic_loadGearTb2"
  &lt;/bean&gt;
  </code></pre>
  
  <p>Can I use above configuration ? </p>
  
  <p>As mentioned here: <a href="http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html" rel="nofollow">http://docs.spring.io/spring/docs/current/spring-framework-reference/html/jms.html</a> </p>
  
  <p><em>Instances of the JmsTemplate class are thread-safe once configured. This is important because it means that you can configure a single instance of a JmsTemplate and then safely inject this shared reference into multiple collaborators. To be clear, the JmsTemplate is stateful, in that it maintains a reference to a ConnectionFactory, but this state is not conversational state.</em></p>
  
  <p>Thanks,<br>
  Anuj</p>