Search code examples
akkacqrsevent-sourcingakka-persistence

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?


Solution

  • 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/