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 .
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>
having persistence unit which is of JTA type
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
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?
精彩评论