The spring-boot-starter-jta-atomikos dependency adds the Atomikos transaction manager to a Spring Boot application so you can run JTA (XA) transactions that span more than one resource, such as two databases or a database and a JMS broker. Spring Boot then auto-configures Atomikos and makes @Transactional methods commit or roll back across all enlisted XA resources as one global transaction.
Treat it as a specialised tool. Distributed XA transactions are slow and complex, and most microservice designs avoid them in favour of local transactions plus the outbox pattern or sagas.
The starter pulls in transactions-jta, transactions-jdbc, transactions-jms and the Atomikos Spring Boot integration classes, along with the Jakarta Transaction API. Spring Boot's AtomikosAutoConfiguration then creates:
UserTransactionManager and UserTransactionImp.JtaTransactionManager that delegates to them, which replaces the JpaTransactionManager or DataSourceTransactionManager.XADataSourceWrapper and XAConnectionFactoryWrapper, so XA data sources and JMS connection factories are wrapped and enlisted automatically.Which Boot versions support it differs. The Atomikos starter exists in the Spring Boot 3.x line with Jakarta namespaces, but support for JTA providers has changed across releases, so check the reference documentation for the exact Boot version you use before choosing it.
A local transaction covers one resource. A global transaction is needed when one unit of work must change several independent resources atomically, for example debiting an account in one database and writing an audit record in a second database. Atomikos coordinates this with the two-phase commit (2PC) protocol:
Resources must support XA. Use the database's XA data source class, not its plain one.
Spring Boot wraps any XADataSource bean for you. With the starter present, declaring spring.datasource properties with type set to an XA class is possible for one source, and for two you define beans yourself.
Each data source needs a unique resource name. PostgreSQL also needs max_prepared_transactions set above zero on the server, otherwise PREPARE TRANSACTION fails.
With both sources enlisted, one annotated method controls the whole unit of work.
If the method throws a runtime exception, Atomikos rolls back both databases.
Atomikos stores a transaction log so it can recover in-doubt transactions after a crash. Spring Boot exposes its settings under spring.jta.*:
Keep the log directory on durable storage, and never delete it while in-doubt transactions may exist. In containers, mount it as a persistent volume.
2PC adds latency, holds locks longer and makes the transaction coordinator a critical component. It also does not fit services you call over HTTP, which are not XA resources.
| Approach | Use when |
|---|---|
| XA with Atomikos | A single application must atomically update several XA databases or queues |
| Outbox pattern | You must update a database and publish an event reliably |
| Saga | A business process spans several services and can be compensated |
No. A single database uses a local transaction, handled by the regular Spring transaction manager. JTA only pays off with several XA resources.
Atomikos supports a non-XA resource as the last participant in some configurations, which gives weaker guarantees. Prefer XA-capable resources.
Set max_prepared_transactions to at least the number of concurrent global transactions, and restart the server.
Narayana is another JTA manager that Spring Boot users commonly run, and Jakarta EE servers ship their own. Pick one based on support in your Boot version.
spring-boot-starter-jta-atomikos makes Atomikos the JTA transaction manager in a Spring Boot application, enlists XA data sources and JMS connections, and makes @Transactional span several resources through two-phase commit. Use it only when you truly need atomic updates across XA resources, persist the transaction log, and prefer outbox or saga designs for service-to-service consistency.