Here's the scenario and by the way, I'm looking for a Java-centric answer.
- Client code calls REST Service A (POST) from Provider Application #1.
- Client code directly updates an internal database using JDBC.
- Client code calls REST Service B (POST) from Provider Application #2.
- Steps 1 to 3 need to occur in a distributed transaction with two phase commit support i.e. if Step 2's database update fails, then we want to undo Step 1's POST. If Step 3's POST fails, we want to undo Step 1's POST and Step 2's database update.
Is there a way we can accomplish this using JTA without writing our own compensation code (to undo Step 1 and 2)?