Hello everybody,
I'm workin on an ES/CQRS project and there is a thing that is not really clear to me. I think I understand how to handle commands and queries in my applications. I stll have some doubts regarding events.
As far as I understand it, there are two cases of events for which I could receive direct notification from the outside:
- external system events: these are not domain events of my application, so they don't need to be stored in my event store, but they just need to be dispatched in the event bus so that my application could react to them;
- offline events: these are domain events, which happen in "real" world and needs to be recorded in my event store so that aggregates could be reconstructed correctly in the future; I'm not sure how I should treat those: should I persist them in the event store as soon as possible or should I perform some kind of validation before doing so? Should the aggregate considered in the event be involved in such checks? Or should I just verify the coherence of my system after the event was persisted with an event listener? Moreover, at the moment it is the aggregate repository who has the knowledge of what stream to use when persisting events, but for "offline" events it would seem wrong to me to pass through the repository. Is this feeling right? Where do you suggest to move the logic that controls the naming of the stream where the event should be persisted?
Thanks