Click here to Skip to main content
15,887,464 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
So I have two microservices, one that has a database and one that make RPC calls to the one that has the database. The one that makes the RPC calls (I called it gui-microservice) has two services, BookService and LoanService. These two services use rest templates to modify the resources in the other microservice (database-microservice).

I have a higher-level operation called checkOut(book) in the gui-microservice. This method will use the BookService's changeAvailabilityToOut(book) and LoanService's createLoan(book). I want to make this higher operation checkOut(book) atomic and roll back if either checkOut(book) or changeAvailabilityToOut(book) fails, kind of like a @Transactional call, but instead of interacting with a database, you are interacting with a rest microservice.
The question is that is there any tools in the Spring library that will help me do that. Is there anything besides architectural changes at all?

What I have tried:

I tried reading up and people just say to change my architecture, but the code is already quite big to do this comfortably. I am trying to research on the @Transactional annotation but nothing turned up.
Posted
Comments
[no name] 22-Dec-21 12:25pm    
Unless a "rollback" is implemented in the service, how do you expect to invoke it "higher up"?
Minh To Quang 23-Dec-21 12:38pm    
Good day! I am not sure if I understand your question, could you please elaborate?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900