简体   繁体   English

如何在j2ee中实现Long运行的分布式事务

[英]how to implement Long running distributed transaction in j2ee

I want to move records from one database to another which are on different machines. 我想将记录从一个数据库移动到另一个数据库,它们位于不同的机器上 the records should be removed from first database and inserted to second database atomically. 记录应从第一个数据库中删除,并以原子方式插入第二个数据库。

can we use xa ? 我们可以使用xa吗? i believe xa uses 2 phase commit algorithm which requires the blocking locks on the resources 我相信xa使用2阶段提交算法,需要对资源进行阻塞锁定

the target database is a EIS database, so it should be locked for minimum time. 目标数据库是EIS数据库,因此应该锁定最短时间。

XA is indeed a 2 phase commit blocking protocol, but in my case there are only two entities involed with the first entity being very fast. XA确实是一个2阶段提交阻塞协议,但在我的情况下,只有两个实体被调用,第一个实体非常快。 so 2PC will work efficiently for me. 所以2PC对我有效。

for a more general scenario 3 phase commit can be used. 对于更一般的场景,可以使用3阶段提交。 it's a non-blocking protocol. 这是一个非阻塞协议。 though dont' seems to have any java specifications. 虽然不“似乎有任何java规范。

also came across BTP and http://jotm.objectweb.org/jotm-btp.html not sure how easily it can fused with JDBC adapter. 还遇到了BTP和http://jotm.objectweb.org/jotm-btp.html不确定它与JDBC适配器融合的容易程度。

XA doesn't have any incidence on the locking mechanism. XA对锁定机制没有任何影响。 It just makes sure that ACIDity is preserved even if you update two separate transactional resources. 它只是确保即使您更新两个单独的事务资源也保留ACIDity。 Your usecase only updates one, if I understand correctly, so XA is not necessary here. 如果我理解正确,你的用例只会更新一个,所以这里不需要XA。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM