开发者

JTA 2PC - with multiple datasource

I am new to JTA and i am trying to implement the JTA 2 pc .In business method

I want if fun1 fails then fun3 should also but its not happening.

@Transactional
fun(){

testDao1.fun1();
testDao2.fun3();
}

I had following things .

  1. Create datasource as .I have multiple datasources

    <bean id="dataSource" class="org.apache.commons.dbcp.managed.BasicManagedDataSource"
        destroy-method="close">
        <property name="driverClassName" value="org.postgresql.xa.PGXADataSource" />
    开发者_StackOverflow中文版    <property name="url" value="${database.interimws.email.url}" />
        <property name="username" value="${database.interimws.email.username}" />
        <property name="password" value="${database.interimws.email.password}" />
         <property name="defaultAutoCommit" value="false" />        
        <property name="maxActive" value="${database.maxactive}" />
        <property name="maxIdle" value="${database.maxidle}" />
        <property name="maxWait" value="${database.maxwait}" />
    </bean> 
    
  2. having persistence unit which is of JTA type

  3. created entityAMangerFactory using the above dataSource and Persistence unit 4.getting the javax.transaction.TransactionManager and Usertransaction object from Server and configured spring jta for annotation

  4. Having a bussiness class which is annotated as transactional.


Make sure that you have XA-type drivers for every database that participates in two-phase commit; otherwise, it won't work.

How are you testing this? Do you have a mock version of DAO1 that throws an exception?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜