Hi I just want to ask question how to correctly handle the events (or how are you handling them), because I’m doing something and I think it’s wrong.
Lets say we have some domains, each can be separate microservice, but all are owned by me.
- Account - holds informations about business account
- User - holds informations about application users
- Group - holds informations about users groups
- Setup - holds informations about application setup
when I create new account, new groups must be created based on some criteria, current user must be added to account (there could be possibly AccountUserRelation domain) and some default setups must be created.
now what is the cleaner approach:
- create AccountSaga and catch AccountCreatedEvent. From this sagaHandler call AddUserToAccountCommand, CreateGroupCommand and CreateSetupCommand
- in each domain (User, Group, Setup) create separate EventHandler (lets say ExternaEventslEventHandler) and hadle the AccountCreatedEvent?
approach 1 has disadvantage, that if I need additional data from specific target domain, I need to get them somehow remotely (e.g. REST)
approach 2 is maybe simpler to use, but it adds commands from another domain what I don’t know if is ok with principles of DDD/CQRS.
what else can I try?
Thanks
Lukas