did you every take into account to support the outbox pattern? You can find a good explanation here: http://www.kamilgrzybek.com/design/the-outbox-pattern/
It’s very powerful whenever your event store is seperated from the persistence unit of the component which emits the event. There are many Axon use.cases:
- Axon Server, Kafka, AMQP,…:
- Separate JPA Persistence Unit in a monolith: The emitting component is managed by a different EntityManager than the event store (this is my concrete use case)
With the outbox pattern you can circumvent a lot of potential problems concerning atomicity.
- The outbox stores the event which should be emitted. This outbox entry is committed within the transaction which also manages the component which emitted the event. This approach ensures that all data changes AND the event are stored in a single transaction.
- A tracker checks for messages in the outbox, publishes the events to the event store and deletes the outbox entries afterswards.
- As the deletion of the outbox entry might fail, it might happen that the same outbox entry is published to the event bus multiple times. Therefore the even bus has to be idempotent.
Maybe I did not get the concepts of Axon entirely, but currently I think something like the outbox pattern is missing. I’m keen to know your opinion.