Search code examples
transactionsjmsjtadistributed-transactionsatomikos

How to propagate JTA transactions to different JVMs?


I have a multi-domain application. Each domain is a separate Spring application providing services and accessing it's own DB using JPA. I'm not using any Java EE container just Jetty to run the domains as web applications. In my project it is a requirement to make it possible to install these domains on remote machines so i can't tie the components to a single JVM. What I'm looking for is a way to make reliable transactions across these domains over the network.

For eg. consider that we have a billing and user-account handling domain and i like to make the new user registration operation atomic which involves the following steps:

  • Create a user account by calling the user domain's function
  • Log the registration fee of the user by calling the billing domain's function

If one of these steps fails, I've expect both domain's database to be rolled back.

I'm currently piloting JTA + Spring + Atomikos based on this article, however this only considers a single JVM. My goal is to setup Atomikos in such way that if a domain running in it's own JVM accepts a JMS message which is part of a JTA transaction started in the caller domain and this listener manipulates the domain's database, the database transactions created will participate in the JTA transaction as well. This way the changes done to the local database is only commited if the JTA coordinator commits the global transaction and not locally at the end of the onMessage function.

This is where i stuck at the moment because i thought that Atomikos could be instantiated separately, not just embedded as the above example shows and Spring application could be configured to use this shared Transaction Manager to register resources in the transaction. But i can't find any tutorial for this, just for local transaction management.

I'm looking for some advice or - even better - a code example which shows how can i achieve this. Atomikos is not required, but i require a non Java EE solution which is not paid.


Solution

  • I am from Atomikos. We offer this capability but alas not as part of our open source / free edition (rather, the paid edition).

    However our prices are pretty affordable (please check our website for details).

    Hope this helps,

    Guy