2017-10-11 18:01 GMT+08:00 Sebastian <
akri...@gmail.com>:
> Do you have other good examples, practices, ... to show the handling of
> domain events in a good way ?
For me the kind of handling you showed doesn't work at all, as my
system is clustered. If all instances do the work examples you had,
and caused side effects, it would get messy.
The way I handle domain events is very simple: each instance in the
cluster subscribes to the event store, gets events, maps to database
updates, and executes those updates. Each instance has a local
database, non-clustered, so that works well. Then, each instance can
answer requests, either reads or writes. If I have jobs that needs to
be done, like the analyseLoginForPossibleHijack, I'll have a cron job
call an endpoint on the system as a whole to trigger it, load balancer
picks an available instance, and the algo runs on the local database
of the selected instance.
That's pretty much it.
/Rickard