-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
example for mongodb transaction with session context #3
Comments
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 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.
The text was updated successfully, but these errors were encountered: