I'm trying to use Atomikos for distributed transactions in my spring boot application. It will interact with the two databases.
I found an example in which the author uses Atomicos. Starting with version 1.2 spring boot supports Atomicos.
I have several questions:
Thanks!
Spring Boot will auto-configure the JtaTransactionManager
for you and bind it properly to your entity manager or JMS message listener, if any. Check the documentation for more details. A safe way of starting is to not write any configuration at all and see what you need to customize via properties or custom configuration.
That being said, Spring Boot has no auto-configuration support for several databases. If you want to configure a project with two databases, you'll have to do it yourself; this sample project shows you how you can do it with JPA and a local transaction manager. You can easily port it to JTA with Atomikos based on the example you've referenced.
You can't change the transaction manager at runtime (i.e. based on the fact that your thread is using only one database). I guess that the transaction manager itself has an optimization for such a case, not running a full 2PC if it does not have to.