Ensuring atomicity of writing to the command store and publishing to the event bus

Hello,

What techniques are axon projects using to make command handling atomic (transactional)? I understand that comand handlers. We are currently considering using activemq as the event bus (most likely backed by an RDBMS). Does choosing a complementary persistence technology (the same RDBMS) for the command store (event sourced) make it the simplest?

Also, when working with Mongo as an event store, how is this atomicity being ensured? Finally, what persistence technologies are typically being used in production for the event store?

Your inputs and advice will be very helpful.

Thanks!

Hi Prem,

since I use Spring in most application, I simply use a SpringTransactionManager on my command bus. They have hooks to connect a RabbitMQ transaction to that same transaction manager, so that publication of events is done transactionally as well.
I always see command handling (including the event publishing part) as a single transaction. Handling events and updating a query store is another transaction. Some projects are pretty simple, and allow you to run everything in a single transaction. In that case, you may benefit from storing the events in the same database as the query models.

Mongo has no transactional guarantees, other than that updates to a single document are atomic. The MongoEventStore allows you to add multiple events as a single document, so that that action is done atomically. However, as far as I know, it is not possible to combine that into a transaction together with the publication.

Cheers,

Allard