简体   繁体   中英

How to handle cross DB transactions

I have a situation where I need to handle cross db transactions. Following are the detailed requirements:

I have 2 DB A and B

1) Both Db must be in synch eventually. Both Db must be EVENTUAL consistency and not strictly consistency.A record may be present in DB A and may not be present in DB B for some time. But eventually it must be present in both DB

2) Both DB do not support transactions/rollback

3) Once you commit in Db B, you cannot undo/delete it.But you can delete a record from DB1

4) It's ok to lose some data. Maybe 10 records in a day

One solution is as follows:

1) Write into DB1

2) Then write in DB2

If writing to DB2 fails, write into file using log4j. This files will then be read and retried to be saved in DB2. Is this approach ok?

That's called two phase commit for ACID databases.

NoSQL doesn't deal with transactions the way that ACID databases do. It's one of the things you choose to give up when you go NoSQL.

I think you have to code this in the service that deals with the databases.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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