MessageHandler MH Sign Up

Maintaining session consistency in a distributed system, using event sourcing


Maintaining session consistency.

You can't always rely on eventual consistency to propagate data throughout a value stream.

When a user is performing several actions in a row, they are usually expecting to get immediate feedback.

One way to solve this is called session consistency.

Session consistency ensures that the active user has a consistent view of the process, while other participants see the effects eventually.


Achieving session consistency in an event sourced system can be done by executing a projection at runtime, in the request process.

Session consistency

The projection rolls up the events in the event stream into a single state object.

By reading the entire event stream on request, and turning it into human readable state, the user will always be looking at the latest state.

The only caveat to this approach is the length of the stream, it needs to be short so that it can be loaded in one go.

If you are designing your systems around business capabilities, this requirement should always be met, as business capabilities are representing short process sections and should be finite by nature.

Event Sourced Aggregate Root

The implementation of the Event Sourced Aggregate Root is the same as it would be in the eventual consistency scenario.

It has the responsibility to decide how the system should respond to a command requested by a user.

The events emitted to capture these decissions, are written to an Azure Storage Table in a single operation, using a so called entity group transaction.

Data Exchange

The main difference with the eventual consistency model is how data is exchanged.

In this model, data is exchanged between User Interface components and not via a messaging backchannel.

Sign up to our newsletter to get notified about new content and releases

You can unsubscribe at any time by clicking the link in the footer of your emails. I use Mailchimp as my marketing platform. By clicking subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.