akka-blog-example icon indicating copy to clipboard operation
akka-blog-example copied to clipboard

Consistency in Application

Open two10 opened this issue 6 years ago • 1 comments

Hello ,

In the sample code sending events on event stream and persisting state is not in a single transaction , this may lead into missing events for upstream for making a consistent view state(CQRS).

How do we tackle this.

two10 avatar Oct 03 '17 06:10 two10

In my example, the event is persisted before being published to the event stream. The snapshots are only relevant for performance and can be recomputed in case of failure from the persistent event log, so I don't think there's an issue there. The state is always computed by "folding over" the stream of events (in my case, I use the BlogState.+() function as my fold operation), so as long as commands are validated before generating an event from them, there shouldn't be an inconsistencies.

I recently read a book, Functional and Reactive Domain Modeling, which goes into a lot more detail about this which I recommend.

jvz avatar Oct 03 '17 14:10 jvz