In java microservices, this is a very common scenario where distributed transaction takes place during the data flow through microservices. I have explained to this blog how to handle this using the Saga pattern in two ways with Java Saga code taking an example of Online Stock Purchase.