Hello,
I already had a discussion with Frans Van Buul on this topic, but he is on holiday at the moment so I hope someone else can help me with this.
In preparation of going to AxonDB, I would like to configure 2 storage engines:
- 1 central event storage engine (MySQL)
- 1 local saga&token storage engine (MySQL)
I almost got this working by following this example:
https://github.com/AxonIQ/giftcard-demo-series/tree/master/giftcard-multiconfig-monolith/src/main/java/com/example/giftcard/infra/two_postgres
In the situation where the event store and the saga/token store is used in 1 transaction, I get the following message:
An event with identifier [f33ec3f2-99d2-4410-bea2-3ace46eea032] could not be persisted
Caused by: javax.persistence.TransactionRequiredException: no transaction is in progress
A concrete example: if you send an event from within a saga, the saga entry table needs to be changed and the event needs to be added in the database, this happens in the same transaction.
Only 1 transaction manager will be asked to create a transaction, and in this example the Event Store didnt start a transaction. For this reason, I got this exception.
If you work with AxonDb, the transactions will probably handled by AxonDb itself.
But in this case, I have 2 datasources … both are managed by two different transaction manager in this example.
Anyone a solution for this? Do I really need a distributed transactions for this?
Kind regards,
Koen Verwimp