MongoDB/AxonServer Transactions

Hi guys,

I just did some tests with our app.

As I read the reference guide, when using AxonServer, events published by the event gateway (or by an Aggregate) should only be sent upon commit of the surrounding transaction. In case of annotation based transaction demarcation that would be, if no exception occurs.

We’re using Axon/AxonServer 4.2 together with MongoDB (4+, which includes transaction management) as tokenstore.

Are there any limitations with regard to transactions when I use this configuration? Does somebody have a sample config? Maybe I’m missing something…

Thanks a lot!

I was imprecise with my question.

What I tried is to execute a method that is marked as @Transactional, which sendAndWait()s a command through the command gateway to an Aggregate (which in turn applies an event).

What I see is that although there is an active transaction, when I intentionally throw a RuntimeException in the method AFTER sending the command, the event will be stored anyway.

If I throw the exception in the command handler, after applying the event, the event will NOT be stored.

So it seems that only the things that happen INSIDE the command handler (UoW) are part of the transaction, but not what happens in the surrounding code, meaning only the command handler’s code is atomical.

Is that right, or do I miss something?

Thanks
Markus

Hi,

I think this topic can be “closed”.

I believe the logic as it is right now is clear and right.

Thanks,
Markus