JMS and the Spring Framework
A Spring Framework application can use the JMSTemplate class to send JMS messages or receive synchronous JMS messages.
The JMSTemplate can locate JMS destinations from their Java™ Naming and Directory Interface (JNDI) name that you configure in an application resource reference.
Alternatively, for Spring Framework Version 2.5 and later, the JMSTemplate can locate JMS destinations through dynamic resolution, which looks up the administrative name of the destination that is configured in WebSphere® Application Server
<bean id="jmsConnectionFactory"
class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName" value="java:comp/env/jms/myCF"/>
<property name="lookupOnStartup" value="false"/>
<property name="cache" value="true"/>
<property name="proxyInterface" value="javax.jms.ConnectionFactory"/>
</bean>
<resource-ref>
<res-ref-name>jms/myCF</res-ref-name>
<res-type>javax.jms.ConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<jee:jndi-lookup id="jmsConnectionFactory" jndi-name=" jms/myCF "/>
<bean id="jmsQueueTemplate" class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="jmsConnectionFactory"/>
</property>
<property name="destinationResolver">
<ref bean="jmsDestResolver"/>
</property>
...
</bean>
<!-- A dynamic resolver -->
<bean id="jmsDestResolver"
class=" org.springframework.jms.support.destination.DynamicDestinationResolver"/>
<!-- A JNDI resolver -->
<bean id="jmsDestResolver"
class=" org.springframework.jms.support.destination.JndiDestinationResolver"/>
At run time, the JMSTemplate object can locate a destination based on its JNDI name that was configured in an application resource reference. Alternatively, the JMSTemplate object can locate a destination by using dynamic resolution, based on the administrative name of the destination configured in WebSphere Application Server.
jmsTemplate.send("java:comp/env/jms/myQueue", messageCreator);
jmsTemplate.send("myQueue", messageCreator);