Mequrel
Mequrel

Reputation: 727

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:

What is the best way to go and why?

Upvotes: 12

Views: 3443

Answers (4)

Jan-Terje Sørensen
Jan-Terje Sørensen

Reputation: 14698

I have also found it difficult to find any good examples on how to approach Akka Persistence and Event Sourcing. Therefore I have created this example application using Dropwizard and Akka Persistence, akka-persistence-java-example

This example uses PersistenceActor for writing data and PersistenceQuery for reading data.

Upvotes: 4

Prakhyat
Prakhyat

Reputation: 1019

There is really nice discussion going on this topic. I am just pasting the conclusion post https://groups.google.com/forum/#!topic/akka-user/MNDc9cVG1To. Hope it should help readers landed in this post.

Upvotes: 0

Ashley Aitken
Ashley Aitken

Reputation: 2529

Whilst I think reading from an EP's journal is a great way to recover / rebuild a View, it seems to be polling the journal (akka.persistence.view.auto-update-interval). This would not be appropriate if one wanted synchronous updates of the read model (which it has been suggested by some may be a good starting point for read models). I would suggest (and like to use myself) the journal for recovery but have some sort of pub-sub architecture for live events. I know this may be very hard but it seems like the right thing to do. However, I am not knowledgable enough to suggest how to do distributed pub-sub with Akka Persistence or other libraries or even sure if it is really practical to do it.

As an alternative, would it be possible for Views to be notified when journals they are following are updated?

Upvotes: 0

Patrik Nordwall
Patrik Nordwall

Reputation: 2426

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/

Upvotes: 4

Related Questions