We are currently using domain driven desing with commands and events. I can not decide in which layer of DDD should event handlers and command handlers resides.
My feeling is it should reside in application layer but I have not proper arguments. My understanding of application layer in brief is, application layer coordinate business tasks and does not hold any domain state.
Event handlers are the coordinators which reacts to message and call domain objects to do their tasks. Most of the time event handlers only decide which command/event(message) will be called next. Or call some API or other domain logic in domain layer, to do the task before further message execution.
Thats the why I think event and command handlers should resides in application layer.
But, now it is getting more complex. We are using Process Managers too. They handles events same as event handlers do. But they contains temporary state. Moreover how they are constructed, they are holders of business logic too. You can read from them how are events chained and what must be achieved to fulfill this particular process.
How should I threat them? Did they belong to application layer or domain layer?
Summary:
- Did event handlers belongs to application layer?
- Did command handlers belongs to application layer?
- Did Process Managers belongs to application layer?