Created
November 3, 2011 14:32
-
-
Save aziz781/1336630 to your computer and use it in GitHub Desktop.
Spring JMS: smaple JMS Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<beans xmlns="http://www.springframework.org/schema/beans" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xmlns:jms="http://www.springframework.org/schema/jms" | |
xmlns:p="http://www.springframework.org/schema/p" | |
xsi:schemaLocation="http://www.springframework.org/schema/beans | |
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> | |
<!-- @author Abdul Aziz --> | |
<!-- SOA : JMS-Queue JNDI provider URL --> | |
<bean id="jndiSOA" class="org.springframework.jndi.JndiTemplate"> | |
<property name="environment"> | |
<props> | |
<prop key="java.naming.factory.initial"> | |
weblogic.jndi.WLInitialContextFactory | |
</prop> | |
<prop key="java.naming.provider.url"> | |
${soa.jndi.url} | |
</prop> | |
</props> | |
</property> | |
</bean> | |
<!-- JMS queue connection factory configuration --> | |
<bean id="jmsQueueConnectionFactory" depends-on="propertyConfigurer,jndiSOA" | |
class="org.springframework.jndi.JndiObjectFactoryBean"> | |
<property name="jndiTemplate"> | |
<ref bean="jndiSOA" /> | |
</property> | |
<property name="jndiName"> | |
<value>${soa.jndi.connection}</value> | |
</property> | |
</bean> | |
<!-- A cached connection to wrap the JMS connection --> | |
<bean id="cachedConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory" | |
p:targetConnectionFactory-ref="jmsQueueConnectionFactory" | |
p:sessionCacheSize="10" depends-on="jmsQueueConnectionFactory"/> | |
<!-- Configuration for send queue --> | |
<bean id="sendDestination" depends-on="propertyConfigurer,jndiSOA" | |
class="org.springframework.jndi.JndiObjectFactoryBean"> | |
<property name="jndiTemplate"> | |
<ref bean="jndiSOA" /> | |
</property> | |
<property name="jndiName"> | |
<value>${soa.jndi.outqueue}</value> | |
</property> | |
</bean> | |
<!-- Configuration for receive queue --> | |
<bean id="receiveDestination" depends-on="propertyConfigurer,jndiSOA" | |
class="org.springframework.jndi.JndiObjectFactoryBean"> | |
<property name="jndiTemplate"> | |
<ref bean="jndiSOA" /> | |
</property> | |
<property name="jndiName"> | |
<value>${soa.jndi.inqueue}</value> | |
</property> | |
</bean> | |
<!-- JMS template configuration --> | |
<bean id="jmsTemplate" class="org.springframework.jms.core.JmsTemplate102"> | |
<property name="connectionFactory"> | |
<ref bean="cachedConnectionFactory" /> | |
</property> | |
<property name="defaultDestination"> | |
<ref bean="sendDestination" /> | |
</property> | |
<property name="receiveTimeout"> | |
<value>30000</value> | |
</property> | |
</bean> | |
<!-- SOA JMS message listener --> | |
<bean id="jmsListener" depends-on="propertyConfigurer" | |
class="uk.gov.nhsbsa.dcss.obs.buss.jms.JmsMessageListener"> | |
</bean> | |
<bean id="jtaTransactionManager" class="org.springframework.transaction.jta.JtaTransactionManager"/> | |
<!-- <bean id="jmsTransactionManager" class="org.springframework.jms.connection.JmsTransactionManager"> | |
<property name="connectionFactory" ref="jmsQueueConnectionFactory" /> | |
</bean> --> | |
<bean id="jmsContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer" depends-on="propertyConfigurer"> | |
<property name="connectionFactory" ref="cachedConnectionFactory" /> | |
<property name="destination" ref="receiveDestination" /> | |
<property name="messageListener" ref="jmsListener" /> | |
<property name="sessionTransacted" value="true" /> | |
<property name="transactionManager" ref="jtaTransactionManager" /> | |
</bean> | |
</beans> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment