I've made some small research about Domain Events, and have found few different solutions
- Udi Dahan solution, which handle events immediately
- Deferred domain events, which fire off in infrastructure mostly
- Domain Events which return result
Questions:
- Which one is a pure Domain Events ?
- Is it possible to have them all in the same project ?
- In that case how should I name and distinguish them ?
- Where to register EventHandler ? Someone mentioned that Application Service is appropriated place, but here I've seen that it was registered right into the Domain Model, and handled there, as well, and not in separate Event handler class.
One more extra question.
For example: When order is created and paid it has to get status "OrderPaid".
Because purchasing and ordering are two different contexts, right after Order was created we need to rise a Domain Event, which should be handled by Event Handler in Purchasing bounded context, but in result of Event Handling, there should be raised one more Domain Event - OrderPaid, which might be handled by Order context again. With monolith application it seems that one solution might be: pass Order object into Event Handlers to achieve expected behavior. Is there any other ways how to solve it, in such architecture style ?