We need to find best way to address distributed transaction management in our microservices architecture.
Here is the Problem Statement.
We have one Composite microservice which shall interact with underlying other 2 Atomic microservices (Which are meant for specific purpose obviously) and have separate database e.g. We can consider these 2 microservices as
Here in Composite Service Usecase is like user
(Administrator) can assign a Teacher to a student for the specific course etc.
I wonder how can we address this problem in one transaction as each servie (STUDENT_SERVICE and TEACHER_SERVICE ) has separate DB and all should happen in one transaction either commit or rollback.
Since those 2 services are separate and I see JTA would not be of help as it is meant for having these 2 applications (services) deployed on same application server!
I have opted out JTA as mentioned above
You could commit them both after they are both successful
Je sais ce que je sais
posted 1 week ago
Al Hobbs wrote:You could commit them both after they are both successful
Agree .But here under the hood updateTeacherServiceAPI(request); is call to microservice 1 & updateStudentServiceAPI(request);is call to microservice 2 . Here how to treat this transaction as 1 as microservice 1
shall have code something like
getConnction of Microservice DB1 commit the txn and reply which is isolated transaction and if updateStudentServiceAPI(request); fails because of some reason I have to reinitiate a txn to microservice 1 saying undo the record update done in updateTeacherServiceAPI(). Which is quite difficult if by the time microservice 1 goes down then ? System shall remain in unConsistent state. I wish to do it with some standard framework if there is already in Springboot distributed Transaction management they way it is in EJB i.e. TransactionalAttributes.