Handling external/offline events

134 views
Skip to first unread message

Marco Perone

unread,
Jan 9, 2017, 6:32:47 AM1/9/17
to DDD/CQRS, s.v...@mvassociati.it
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

João Bragança

unread,
Jan 9, 2017, 10:24:56 AM1/9/17
to ddd...@googlegroups.com
For external events, it's probably better to store a copy of them in your event store. What happens if you have a projection based off these events that you need to rebuild, and another one that does not? You will not be able to get the external system to 'redispatch' them to you without a lot of faffing about, and certainly not with any ordering guarantees. By recording them in your system first, you can at least keep deterministic ordering of the events *as you observed them*. Also you can avoid bifurcating your subscription mechanism this way.


--
You received this message because you are subscribed to the Google Groups "DDD/CQRS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/dddcqrs.
For more options, visit https://groups.google.com/d/optout.



--

Marco Perone

unread,
Jan 9, 2017, 11:34:31 AM1/9/17
to DDD/CQRS, joao...@braganca.name
At the moment I don't have any projection connected to my external events. I'm using them to trigger a process manager that dispatches a command to my application. So at the moment I am not worried about replication of external events.

Thanks for the links about offline events, I'll have a look at them!
To unsubscribe from this group and stop receiving emails from it, send an email to dddcqrs+u...@googlegroups.com.

Visit this group at https://groups.google.com/group/dddcqrs.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages