Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CQRS + Event Sourcing implementation using akka-persistence

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?

like image 781
Mequrel Avatar asked Mar 18 '14 09:03

Mequrel


People also ask

What are the best resources to learn Event Sourcing with AKKA?

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.

How does Akka persistence work?

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.

Can Event Sourcing and CQRS be used together?

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.

Why is CQRS system performance important?

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.


1 Answers

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/

like image 148
Patrik Nordwall Avatar answered Sep 22 '22 06:09

Patrik Nordwall