5

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 ? i believe xa uses 2 phase commit algorithm which requires the blocking locks on the resources

the target database is a EIS database, so it should be locked for minimum time.

Sumeet Jindal
  • 882
  • 1
  • 7
  • 16

2 Answers2

1

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. so 2PC will work efficiently for me.

for a more general scenario 3 phase commit can be used. it's a non-blocking protocol. though dont' seems to have any java specifications.

also came across BTP and http://jotm.objectweb.org/jotm-btp.html not sure how easily it can fused with JDBC adapter.

Sumeet Jindal
  • 882
  • 1
  • 7
  • 16
0

XA doesn't have any incidence on the locking mechanism. It just makes sure that ACIDity is preserved even if you update two separate transactional resources. Your usecase only updates one, if I understand correctly, so XA is not necessary here.

JB Nizet
  • 678,734
  • 91
  • 1,224
  • 1,255
  • a local transaction. You're updating a single database. Whether the data comes from the GUI or form another database doesn't matter. Use your target database exactly as in any other use-case which updates the database. – JB Nizet Nov 30 '11 at 12:43
  • if i use a local transaction then it is possible that the data is commited to the target but not cleared from the source. – Sumeet Jindal Nov 30 '11 at 12:46
  • Ah, OK. So you don't need to just insert data in the target database. You must also remove it from the source database. Then if you want ACIDity, XA is required. – JB Nizet Nov 30 '11 at 12:53