Blog Logo
TAGS

Dont Fail Publishing Events! Event Driven Architecture Consistency

Duration : 00:11:24

Consistency is crucial when working with event-driven architecture to ensure that relevant events are published when making state changes. This is because events are first-class and driving workflows and business processes. A minor change in the eShop on web sample application shows the potential issues with publishing events before persisting. Firstly, a race condition may occur when a consumer needs to access the database for an order created, but it has not been persisted yet. Secondly, if persisting fails after publishing an event, it misleads and disturbs the consistency of the system. The solution is to switch around saving state to the database before publishing the event and having a fallback for publishing messages to ensure availability.