My problem schematically is:
- service A beginning transaction;
- service A prepared and save any data to DB
- service A make some (HTTP-REST) request on service B
- if service B success responded (and saved data), then A commit transaction
- If service B throws any exception - service A rollback transaction
The problem is that service B just responded slowly and service A caught a timeout exception and rolled back the transaction. Service B, however, processed the data (although it did not respond in time). When, the process is considered successful if both service A and service B have saved and processed the data. In this case, due to the rollback of the transaction, the data of service A was not saved.
Is there a general solution to this problem? I look towards 2PC and event-based distributed transactional mechanism (such as saga pattern). Thans for any help/links/etc.