4

I have recently watched several videos about ES and CQRS models as well as I have watched few talks about AKKA persistence. I know what they are about but I have issues writing actual code that will execute.

I have few questions though. How should i make view and event stack communicate? Will events be passed between view and persistent actor of same persistence id passed? What are persistent actor and view responsible for according to the model?

Edit: Where should i place my business logic? According to model i should do that in write, but what if i need to check something in read to validate cmd?

Haito
  • 2,039
  • 1
  • 24
  • 35
  • 1
    Sometimes I have a feeling like the whole Akka community is avoiding that question. Anyways, `PersistentView` is deprecated so I was personally advised to use Akka Persistence Query instead. On read side, you will project all events in your read actor and update your read store (some database). Persistent actor is responsible for writing events into a event store (also some database), replying them and using them to update its state. Hopefully, someone will make a small example to finally clarify PROPER implementation of ES and CQRS in Akka. – Branislav Lazic Jul 12 '16 at 19:07
  • @BranislavLazic Thank you kind sir. That's what i needed to know. I looked up a tons of material and each aproach was kinda different. That's too bad that akka docs aren't that good like elixir ones... – Haito Jul 13 '16 at 06:44
  • See http://stackoverflow.com/a/42941900/2113120 and http://stackoverflow.com/questions/38246786/akka-persistence-query-event-stream-and-cqrs – Cal Mar 22 '17 at 03:14

1 Answers1

0

You shouldn't need to check something in your read mode to validate a command - your command would execute against your write model.

Your business logic would go in your write side, if using Akka then inside an Actor.

You haven't said what your view is so there could be multiple ways of communicating - for example, if a web page you could do req/res, or use something like SignalR

tomliversidge
  • 2,339
  • 1
  • 15
  • 15
  • I wanted to use PersistenceView from akka persistence but it become deprecated. I know that logic goes to write model, but if i need to check whether something happened earlier? As far as i understand that information is stored in state which is held by the view. So should i just spam messages between read and write? – Haito Jul 11 '16 at 10:02
  • It might help if you describe the actual issue as it's difficult to understand when such an abstract description – tomliversidge Jul 11 '16 at 12:06
  • Well i just missunderstood the idea and everything is clear now. – Haito Jul 13 '16 at 06:23