2

Initially i was using different transaction manager for multiple data sources. But i had problem with managing rollback on all data sources if one of the data sources has transaction failure.I want to manage multiple datasources with single Transaction manager in Spring. So i opted for using JOTM or Atomikos. Both these transaction manager uses XA Connection pool(org.enhydra.jdbc.pool.StandardXAPoolDataSource). But in my project i was allowed to use only DBCP 2(org.apache.commons.dbcp.BasicDataSource) or Tomcat Connection Pool(org.apache.tomcat.jdbc.pool.DataSource). Is it possible to use either of this connection pools with JOTM or Atomikos. Please someone help me on this along with configuration example. Below is my configuration details,

<

bean id="jotm" class="org.springframework.transaction.jta.JotmFactoryBean"/>

    <bean id="txManager" class="org.springframework.transaction.jta.JtaTransactionManager"> 
    <property name="userTransaction" ref="jotm" /> 
    </bean>

    <bean id="dataSource1" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown"> 
    <property name="dataSource"> 
    <bean class ="org.enhydra.jdbc.standard.StandardXADataSource " destroy-method ="shutdown"> 
    <property name="transactionManager" ref="jotm" /> 
    <property name="driverName" value="${jdbc.d1.driver}" /> 
    <property name ="url" value = "${jdbc.d1.url}" /> 
    </bean> 
    </property> 
    <property name="user" value="${jdbc.d1.username}" /> 
    <property name = "password" value="${jdbc.d1.password}" /> 
    </bean> 

    <bean id="dataSource2" class="org.enhydra.jdbc.pool.StandardXAPoolDataSource" destroy-method="shutdown">
    <property name="dataSource"> 
    <bean class ="org. enhydra.jdbc.standard.StandardXADataSource " destroy-method ="shutdown"> 
    <property name="transactionManager" ref="jotm" /> 
    <property name="driverName" value="${jdbc.d2.driver}" /> 
    <property name="url" value="${jdbc.d2.url}" /> 
    </bean> 
    </property> 
    <property name="user" value="${jdbc.d2.username}" /> 
    <property name = "password" value ="${jdbc.d2.password}" /> 
    </bean>  

Also do help if any other possible ways to achieve this.

user3615185
  • 55
  • 1
  • 8

0 Answers0