I have a system that contains customer
entity and user
entity.
Customer
is a person who pays money. Each customer contains 1-N users. Customer has links to Users.
User
can not exist without customer. User entity contains CustomerId.
The problem is that I am restricted to use specific UI for creating Customers. The process of customer creating consists of 2 steps in UI:
The main idea is to create customers and users at the end of step 2. That would be simple if I could store both of the entites at the same DB. I could do it in one ACID transaction. It would save all or nothing.
Unfortunately I use microservices - Customers and Users are different microservices with theit own storage. And both of the storages are not databases - storage has no transaction options. So Customer
entity uses storage 1 and User
entity uses storage 2.
I have suggested to save Customer after the first step. And then save users after the second step. But there is a cancel button at the second UI step which should delete all users and the customer which were created during whole process. Suggestion was refused. The problem is that in case user with specific username already exists, I shouldn save nor customers, nor users.
My questions are:
P.S. I dont like the the idea of saving users inside customers. In case of chanhging user, I need to work with customer. Another problem is that I need users to be unique in the whole system and need to get list of all users.
P.S. I user Azure Service Fabric and Actors model.
How many RootAgregates do I have? One or two?
Is it a correct approach to store Users in different storage than Customers storage?
Take a look at Effective Aggregate Design by Vaughn Vernon for how to design aggregates.