atomic event consistency between event store and published message (2PC)

253 views
Skip to first unread message

Pankaj Sharma

unread,
May 24, 2017, 11:12:59 AM5/24/17
to Axon Framework Users
My application requires storing the events in the database and also publish the events to a queue. How does axon manages the transaction when the event published needs to be saved in database(mysql/oracle) and the event needs to be pushed to rabbbitmq/ kafka.

I do not want to use 2 phase commit for this but at the same time, I want to ensure that event is successfully published to rabbitmq and also stored in the database.
For cases such as either database or rabbitmq is not available, the transaction needs to be atomic.

What is the general recommendation here?
Can I just publish message to rabbitmq as part of command processing and listen to the event on a queue and store the event in the eventstore?

Eventuate is one framework that avoids 2PC by only persisting the events in JPA store and then reads the data from data store (i believe transaction logs in case of mysql) to publish events. I want to know how axon handles the persisting the events and publishing messages.

Allard Buijze

unread,
May 26, 2017, 11:16:11 AM5/26/17
to Axon Framework Users
Hi,

Check out the SpringAMQPPublisher. It will automatically publish events to AMQP after they are stored in the Event Store (or published on the bus). You can make the SpringAMQPPublisher 'transactional'. In that case it will publish events in a transaction, that it will commit when the transation to the event store has also committed. Not 2PC, just 2 transactions.

Cheers,

Allard

--
You received this message because you are subscribed to the Google Groups "Axon Framework Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to axonframewor...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages