I want to use akka-persistence event sourcing feature in order to implement CRQS + Event Sourcing idea in my new project. The problem is that besides the documentation (http://doc.akka.io/docs/akka/snapshot/scala/persistence.html) I couldn't find any good examples or guidelines how to approach it. The documentation is great in terms of explaining all building blocks of the architecture like processors, views, channels but does not explain how to put them together.
So the question is: how I should connect a write model with read models in akka-persistence? I came up with three options:
Direct connection EventsourcedProcessor -> View, the View receives all events directly from the journal. It seems the simplest solution, but I wonder if we can distribute processor and view on different nodes using this approach.
EventsourcedProcessor -> Channel -> View/normal Actor. What is the difference with the first option? If this is the right solution, why we have Views in akka-persistence building blocks? Should I use Channels or PersistentChannels ?
EventsourcedProcessor -> some kind of event bus (e.g. context.system.eventStream) -> Views/Actors.
What is the best way to go and why?
The Event Sourcing with Akka 2.6 video is a good starting point for learning Event Sourcing, together with the Microservices with Akka tutorial that illustrates how to implement an Event Sourced CQRS application with Akka Persistence and Akka Projections.
Akka persistence supports event sourcing with the UntypedPersistentActor abstract class. An actor that extends this class uses the persist method to persist and handle events. The behavior of an UntypedPersistentActor is defined by implementing OnRecover and OnCommand methods. This is demonstrated in the following example.
We can solve the last two problems that occur when using Event Sourcing method (re-creating the asset every time and filtering the asset according to its areas) together with CQRS. For this reason, Event Sourcing and CQRS are frequently mentioned together. There are reading and writing models on the CQRS Design Pattern.
For this reason, CQRS systems performance is important. Event Sourcing is a method shaped on the main idea of accumulating events that took place in our system. Objects that are one of the main parts of the system that have an identity are called entities. In systems developed with Event Sourcing, the latest status of the assets are not recorded.
EventsourcedProcessor -> View is the way to do it. The view replays from the journal, so you need a distributed journal when placing the view on another machine. List of journal implementations can be found here: http://akka.io/community/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With