title: How to rollback distributed transactions?
body: <p>I have three different Spring boot Projects with separated databases e.g account-rest, payment-rest, gateway-rest.</p>
  
  <ol>
  <li>account-rest : create a new account</li>
  <li>payment-rest : create a new payment</li>
  <li>gateway-rest : calls other endpoints</li>
  </ol>
  
  <p>at gateway-rest there is an endpoint which calls the other two endpoints.</p>
  
  <pre><code>@GetMapping("/gateway-api")    
  @org.springframework.transaction.annotation.Transactional(rollbackFor = RuntimeException.class)
  public String getApi()
  {
      String accountId = restTemplate.getForObject("http://localhost:8686/account", String.class); 
      restTemplate.getForObject("http://localhost:8585/payment?accid="+accountId, String.class);
      throw new RuntimeException("rollback everything");      
  }
  </code></pre>
  
  <p>I want to rollback transactions and revert everything when I throw exception at gateway or anyother endpoints.</p>
  
  <p>How can I do that ? </p>