Open Ja7ad opened 2 years ago
I have take a look at your repo, and there is only a picture describing the logic.
Because MongoDB does not support XA transaction, so you should implement to rollback service manually and submit the update and rollback urls to DTM like this:
saga := dtmcli.NewSaga(DtmServer, shortuuid.New()).
// add a TransOut sub-transaction,forward operation with url: qsBusi+"/TransOut", reverse compensation operation with url: qsBusi+"/TransOutCom"
Add(qsBusi+"/TransOut", qsBusi+"/TransOutCom", req).
// add a TransIn sub-transaction, forward operation with url: qsBusi+"/TransIn", reverse compensation operation with url: qsBusi+"/TransInCom"
Add(qsBusi+"/TransIn", qsBusi+"/TransInCom", req)
// submit the created saga transaction,dtm ensures all sub-transactions either complete or get revoked
err := saga.Submit()
If you want me the help, you should firstly add some docs for a new developer to run your example project easily.
Ok MonogoDB having oplog on replica and logging any trigger on documents.
I will try add saga pattern for test
Maybe you should finish your project without distributed transactions, and then consider how to add dtm to it.
I take a look at your project, client logics, rollback functions are not completed
hi It is my first time working with DTM for transactions in a microservice architecture. Using mongodb in my services, I need more examples of distributed transactions. MongoDB has transaction logic, but I do not know how to use DTM to roll back a session transaction in MongoDB. I want add dtm to my example project: https://github.com/Ja7ad/Library Please help me for this.