Domain events are well known in DDD, which can be published in Aggregate Roots or in Domain Services. My question here is, Can domain events be published in application services/use cases?
For example, simplifying. I have an application service called UseCaseA, which performs various operations calling some aggregate roots. If I want to raise an event when this use case ends, could I publish the UseCaseAFinished event within this application service? Is it a domain event or should it be called an application event? Does application event terminology exist in DDD?
Thanks in advance.
Can domain events be published in application services/use cases?
Usually not: domain information belongs to the domain model, not to the application.
Now, it is normal for the business to be interested in the progress/termination of a process. But that's just a clue that suggests that the process itself is something that should also be modeled in the domain.
"Application events" would be more likely dedicated to application concerns: think "observability".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With