1

I'm playing around with Atomikos. Using this as a starting point: https://www.fabiomaffioletti.me/blog/2014/04/15/distributed-transactions-multiple-databases-spring-boot-spring-data-jpa-atomikos/

In my use case, I'm going to have essentially two physically separated databases that are going to be identical.

This requirement is based on GDPR and basically, we will have databases in different regions.

Some of the tables need to be in sync and one of the ideas is to use Atomikos (2-phase commit ) to implement distributed transactions.

What I'm trying to implement is to use one single spring repository that is going to persist data into two physically divided databases.

All examples provided by atomikos are dealing with two databases but with different tables using different repositories.

Is it possible to configure atomikos on the way that I'm using a single repository that is going to persist data in both data sources?

In the ideal case, I'm looking for the possibility to mark service method with a specific annotation and specific transaction manager and only in that case to force that specific method or better to say invoked repository methods in that service methods ( save, saveAll methods and so on ) to persist data in both databases. When there is no specific annotation on a service method to persist only in a single database to not perform distributed transaction.

Haris Hajdarevic
  • 1,535
  • 2
  • 25
  • 39

0 Answers0