DDD, Can aggregate event processing from another aggregate?

Is it correct to handle the event in an aggregate published from another aggregate? Or should a domain only process commands?

In my case, I have an application that controls the settings. I have an aggregate for an application and an aggregate for a group of applications. When I want to create settings for a specific application group, then the command is processed by my application group, then the application group publishes the GroupSettingsCreated event, but DDD says that we can process this event directly in my ApplicationAggregate? Or should I handle this event in an event handler, match it in a command, and send it to my ApplicationAggregate?

thanks

John

+4
source share
3 answers

If you are tempted to process one aggregated event inside another aggregate, the handler must be a child of the aggregate that generates the event.

In other words, in this limited context, Application should be a child of ApplicationGroup , and ApplicationGroup.CreateSettings() should extend the settings to its child applications.

Another way to think about it: an โ€œapplication groupโ€ may not be a true aggregate, but a convenience provided by the user interface.

+1
source
John, I donโ€™t know anything in DDD that speaks to your question. This is indeed a matter of Event Driven Architecture (EDA) and Responsibility for Team Segregation Request (CQRS).

To give more specific advice, I would like to know what roles the application objects and application groups play. By the way, they are more like application / infrastructure concepts than domain concepts.

In general, I use commands where the next action is logically popped from the source (the next action is the next next step). I use events when the action in question is logically a reaction to upward behavior (the upstream code does not know about this reaction to what just happened).

0
source

You should not do it this way because it will result in messy code. Use sagas to orchestrate instead . Here is a good video from Andreas Olund in the sagas at NServiceBus.

0
source

All Articles