Is it right to handle an event in a aggregate published from another aggregate ? Or a domain should only handle commands ?
In my case, I have an application which manages settings. I have an aggregate for application and an aggregate for applicationGroup. When I want to create a settings for a specific group of applications, then the command is handled by my applicationGroup, then the applicationGroup publish an event GroupSettingsCreated, but does DDD say we can handle this event directly in my ApplicationAggregate ? Or should I handle this event in an event handler ,map it into a command then send it to my ApplicationAggregate ?
Thanks
John
If you're tempted to handle one aggregate's event inside another aggregate, the handler should be a child of the aggregate generating the event.
In other words, in this bounded context, Application
should be a child of ApplicationGroup
and ApplicationGroup.CreateSettings()
should propagate settings to its child applications.
Another way to think of this: an "application group" might not be a true aggregate - but rather a convenience provided by the user interface.
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