Java – when to use global transactions or spring AOP for transactions

Q1. I know that when we need to deal with multiple databases, we need to use global transactions But from this article http://fogbugz.atomikos.com/default.asp Start The recommender only needs to use spring AOP to make recommendations on different transaction managers (more > datasource / sessionfactory) Anyone can explain under what circumstances we can use this method, and under what circumstances we need Xa (global transaction) with atomikos or jotm or EJB etc

Solution

If you mean this message http://fogbugz.atomikos.com/default.asp?community.6.596.2 , then the important part of the op problem is:

In other words, the op will not get multiple transaction resources, he will use one of them (and explicitly write that he does not really need XA support) Therefore, he does not really need global transaction support. He can only use local transactions, and using J2EE transaction manager is not mandatory for his use cases

This is what the answer implies: using atomikos is not necessary and may be a bit over - right

Using two datasources, two txmanagers and two txadvice and defining distinct < AOP: advisor / > elements with different 'pointcut' and 'advice ref' attribute values will allow completely different transaction configurations to be applied to different service layer objects / methods

For details, see section 9.5.1 4. Configuring different transactional semantics for different beans section

However, if you need to use multiple transaction resources (usually relational databases and message queues), you need global transaction support, which means that J2EE transaction manager (provided by J2EE application server, or independently provided by atomikos, jbossts, jotm, etc.)

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>