The problem
So you're splitting up that monolith into smaller scoped microservices. Then you suddenly realise that what used to be one transaction is now split across multiple processes. It's not easy to make multiple updates across multiple processes and guarantee consistent commit or rollback in case of failures. So what can you do?
The solution
Based on popular demand, we at Atomikos have come up with a solution to manage distributed transactions across separate REST microservices. You can now have atomic, consistent commit or rollback spanning multiple microservice processes.

JAX-RS interceptors
Extending the transaction scope across microservice calls is done via JAX-RS "filters" that intercept incoming and outgoing requests and responses, adding / extracting the necessary information to / from the HTTP headers of the request. Here's how to configure this in your code:
Client-side interceptors
import com.atomikos.remoting.jaxrs.TransactionAwareRestClientFilter; javax.ws.rs.client.Client paymentClient = ClientBuilder.newClient(); paymentClient.register(TransactionAwareRestClientFilter.class);
The client interceptor automatically detects any active Atomikos transaction in the client JVM and propagates it in the outgoing calls via HTTP headers - so the server on the other end can extract and join that transaction. It also extracts any URLs from the response headers for committing the work of the other end as part of the active transaction.
Server-side interceptors
import com.atomikos.remoting.jaxrs.TransactionAwareRestContainerFilter; import com.atomikos.remoting.twopc.AtomikosRestPort; JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean(); //we used CXF for our demo sf.setProvider(new TransactionAwareRestContainerFilter()); sf.setResourceProvider(new SingletonResourceProvider(new AtomikosRestPort()));
The server interceptor detects any transaction propagation in the incoming calls - so it can join that transaction. It also adds HTTP headers to the response, containing a URL to commit its work as part of the transaction of the caller. The AtomikosRestPort listens on the URL and awaits commit requests.
Spring REST interceptors
We have similar interceptors for Spring REST, if you prefer that framework over JAX-RS.
Spring Http Invoker interceptors
The Spring HTTP remoting technology is also supported.
Benefits
Some of the benefits of this technology include:
- Consistent commit or rollback is now possible across different microservices.
- If you call a service and get no response (or an exception) then you know it has not committed anything.
- If you refactor your architecture towards microservices then you don't have to worry so much about consistency.
Try for yourself
This post describes real, working examples of our code base. Download the free open source edition here:
Free DownloadAre you serious about REST transactions? Apply here for a free trial of our commercial edition!
- ENJOY FREE EVALUATION SUPPORT: get on-boarded fast - no need to wait for paperwork
- Evaluate the full set of power functionality exclusive to customers
- Avoid late risks by upgrading to the real thing today - so you're all configured to go live without stress
- No rush or hard deadlines - pay only when you're happy and ready to go live
- NOT AVAILABLE IN CHINA
Trusted By



