I have a multi tenant webapp. When a new tenant is created there is a bunch of defaults and configurations that need to be created in the DB for the new tenant, so of these inserts are related to each other and must happen in a specific order so I can get the ID of the related item. Here is an short version of what needs to happen
POST tenant
-> insert default group
-> insert user
-> (next can happen at same time)
—-> insert workflow
—-> insert dashboard
—-> insert fields
-> insert views
(requires field
ids)
Currently in my POST tenant API which I am using spring boot java, for the insert group and user I make synchronous calls to the respective micro services, then upon getting the reply, I make aysnc calls to workflows
, dashboard
and fields
. However now that I am adding views
which is dependent on fields
that call can’t be async and I would need to the wait and call view
.
As I add more and more config this will keep growing and become unmaintainable. Instead of using APIs I am thinking about using queues to kick off the multiple config inserts. Is that the right approach?
My gut is telling me there is a better way to set up each tenant when it is created. What other options should I look at?
1