title: Shared transaction between multiple applications
body: <p>we got a requirement of create a transactional operation but handled through multiple applications.</p>
  
  <p>I'm familiar with <code>@Transactional</code> annotation to achieve transactions, or for example using it programmatically like:</p>
  
  <pre><code>@Autowired
  private EntityManagerFactory emf;
  
  public void doSomething() {
      EntityManager em = emf.createEntityManager();
      EntityTransaction tx = em.getTransaction();
      tx.begin();
      em.createNativeQuery("...do something...").executeUpdate();
      tx.commit();
      em.close();
  }
  </code></pre>
  
  <p>So, if I need to allow an app to create a transaction dynamically I could pass <code>em</code> as parameter and populate multiple operations from different methods.</p>
  
  <p>However, we got a weird requirement to achieve something like above code but involving multiple applications that share the same database, it would be like a distributed transaction.</p>
  
  <p>Is this feasible with Spring? I'm not sure if I might create some rest services where one of the parameters are the serialized entity managers, although this looks very weird to me. Is it possible to handle like a shared transaction populating operations through multiple apps?</p>