Imagine you have a user registration form, where you fill in the form:
First Name, Last Name, Age, Address, Prefered way of communication: Sms, Email (radiobuttons).
You have 2 microservices:
- UserManagement service
- Communication service
When user is registered we should create 2 aggregates in 2 services: User in UserManagementContext and UserCommunicationSettings in Communication.
There are three ways I could think of achieving this:
- Perform 2 different requests from UI. What if one of them fails?
- Put all that data in User and then raise integration event with all that data, catch it in CommunicationContext. Fat events, integration events shouldn't contain domain data, just the ids of aggreagates.
- Put the message in the queue, so both contexts would have the adapters to take the needed info.
What is the best option to split this data and save the information?