Hi Saral
Please find the attached configuration file, it will solve your problem.
On any error occuring anywhere in the transaction, it will rollback the transaction from the database as well as it will send the JMS message to the error queue.
Make sure that the methods of the following two classes should partcipate in the transaction com.XXX.ods.test.service.MyMessageListener.java and
com.XXX.ods.test.dao.MyMessageListenerDAO
you can do so by annotating the methods with
@Transactional(propagation = Propagation.REQUIRED, rollbackForClassName = { "java.lang.Exception" })
and yes most importantly dont forget to configure your Queue Connection factory, Queue and Datasource on your Websphere server and use it in your xml using jndi as I have shown below.
and yes both the resource managers should be XA based.
If you want I can send you the configuration for Queue Configuration factory ,Queue and DS
<?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:int="http://www.springframework.org/schema/integration"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:int-file="http://www.springframework.org/schema/integration/file"
xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
xmlns:int-mail="http://www.springframework.org/schema/integration/mail"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:stream="http://www.springframework.org/schema/integration/stream"
xmlns:jdbc="http://www.springframework.org/schema/integration/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schem...ring-beans.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schem...ration-2.0.xsd
http://www.springframework.org/schema/jms http://www.springframework.org/schem...ng-jms-2.5.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schem...spring-jee.xsd
http://www.springframework.org/schema/integration/file
http://www.springframework.org/schem...n-file-2.0.xsd
http://www.springframework.org/schema/integration/jms
http://www.springframework.org/schem...on-jms-2.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schem...ing-tx-3.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schem...g-task-3.1.xsd
http://www.springframework.org/schem...gration/stream
http://www.springframework.org/schem...stream-1.0.xsd
http://www.springframework.org/schema/integration/mail
http://www.springframework.org/schem...n-mail-2.0.xsd
http://www.springframework.org/schema/integration/jdbc
http://www.springframework.org/schema/integration/jdbc/spring-integration-jdbc-2.0.xsd">
<bean id="placeholderConfig"
class="org.springframework.beans.factory.config.Pr opertyPlaceholderConfigurer">
<property name="location" value="classpath:config.properties">
</property>
</bean>
<jee:jndi-lookup id="queueConnectionFactory1" resource-ref="true"
jndi-name="jms/ODSQueue1" />
<jee:jndi-lookup id="InboundQueue1" resource-ref="true"
jndi-name="jms/Queue1" />
<jee:jndi-lookup id="queueConnectionFactory2" resource-ref="true"
jndi-name="jms/ODSQueue2" />
<jee:jndi-lookup id="InboundQueue2" resource-ref="true"
jndi-name="jms/Queue2" />
<!-- In Bound Process Configuration Starts -->
<int:channel id="dbupdateChannel"></int:channel>
<int:channel id="fileOutPutChannel"></int:channel>
<int-jms:message-driven-channel-adapter
id="mq-message-listner1" container="messageListenerContainer1"
channel="dbupdateChannel" />
<int-jms:message-driven-channel-adapter
id="mq-message-listner2" container="messageListenerContainer2"
channel="dbupdateChannel" />
<bean id="messageListenerContainer1"
class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
<property name="connectionFactory" ref="queueConnectionFactory1" />
<property name="destination" ref="InboundQueue1" />
<property name="messageListener" ref="MyMessageListenerService" />
<property name="sessionTransacted" value="false" />
<property name="cacheLevelName" value="CACHE_NONE" />
<property name="transactionManager" ref="myTxManager" />
</bean>
<bean id="messageListenerContainer2"
class="org.springframework.jms.listener.DefaultMes sageListenerContainer">
<property name="connectionFactory" ref="queueConnectionFactory2" />
<property name="destination" ref="InboundQueue2" />
<property name="messageListener" ref="MyMessageListenerService" />
<property name="sessionTransacted" value="false" />
<property name="cacheLevelName" value="CACHE_NONE" />
<property name="transactionManager" ref="myTxManager" />
</bean>
<int:service-activator id="updateDB" input-channel="dbupdateChannel"
output-channel="fileOutPutChannel" ref="MyMessageListenerServiceDAO"
method="updateDB">
</int:service-activator>
<bean id="myTxManager" class="org.springframework.transaction.jta.JtaTran sactionManager"/>
<bean id="MyMessageListenerService"
class="com.XXX.ods.test.service.MyMessageListener" >
<property name="myMessageListenerDAO" ref="MyMessageListenerServiceDAO"></property>
</bean>
<bean id="MyMessageListenerServiceDAO"
class="com.XXX.ods.test.dao.MyMessageListenerDAO">
<property name="jdbcTemplate" ref="jdbctemplate"></property>
</bean>
<bean id="jdbctemplate"
class="org.springframework.jdbc.core.JdbcTemplate" >
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="dataSource"
class="org.springframework.jdbc.datasource.WebSphe reDataSourceAdapter">
<property name="targetDataSource">
<bean
class="org.springframework.jndi.JndiObjectFactoryB ean">
<property name="jndiName" value="jdbc/ods" />
</bean>
</property>
<property name="username" value="root" />
<property name="password" value="admin" />
</bean>
<int-file:outbound-channel-adapter
directory="${DirectoryForRequestFile}"
filename-generator-expression="headers.getCorrelationId()+'.xml'"
temporary-file-suffix="_swp" channel="fileOutPutChannel" />
<!-- In Bound Process Configuration Ends -->
</beans>
and yes when did you get the Senior Member position...we'll discuss about it later