I have an usecase(migrate data from Oracle to MongoDB via Java app) where I required to implement transaction management to ensure "all-or-nothing" in the datastore.
- Read the input data from Oracle Table (eg: sourcetable).
- Execute two separate stored procedure with that input and process the output cursor and construct two different Mongo document (that get interested into two different collections in a same datasource[collection1 & collection2] respectively).
- If the above steps completed successful then update the above Oracle table (eg: sourcetable) with the status as migration successful.
- Perform commit(both MongoDB & Oracle) only if all the above steps completed successfully.
- If any error at any step perform Rollback on the entire transaction.
I see Oracle offers Two Phase Commit and MongoDB offers Distributed Transactions to achieve these things separately but,I was looking for the way to achieve it together. Also, I have no clue on how to implement it or is that the right solution to my use case or not. I really appreciate for any guidance or pseudo code implementation.
Note: All these process will execute in a distributed environment.