Hello,
in my spring boot app I use MultiSchemaMultiTenantProcessEngineConfiguration to implement multitenancy.
I have some rabbit listener which listens when a new tenant exists and registers it with registerTenant method of MultiSchemaMultiTenantProcessEngineConfiguration.class.
I was wondering if there we any sequences if registerTenant runs twice (e.g. by different threads) for the same tenant and datasource.
I use
config.setDatabaseSchemaUpdate(AbstractEngineConfiguration.DB_SCHEMA_UPDATE_TRUE);
so I guess the schema will be ok, but how about the async executor (I have ExecutorPerTenantAsyncExecutor)?
I tried to reproduce the case and it seems that only one is created per tenant.
Hey @desp.kaz,
You’ll need to implement your own logic to avoid registering an already registered tenant. I would say that it is not advisable to call the registerTenant
twice from different threads in the same time.
Cheers,
Filip
Thanks for the answer Filip!
My initial problem was that I may have many kubernetes pods(instances of the app) that should all be aware of the tenants. If only one pod calls the registerTenant method at my listener then I guess that tenantAwareDataSource won’t be updated for the others, right?
Yes indeed, the tenantAwareDataSource
is a based on a single node implementation. If you have a multi node scenario with a dynamic configuration of those tenants then you should implement something on your own.
Cheers,
Filip
1 Like
Thanks!
Just one last question, at my custom implementation the async executor must be created once? Or does it make sense to have one per instance-pod?
I am not entirely sure how this works exactly.
It should be one per instance / pod. Otherwise, only one pod will be able to handle async jobs for that particular tenant.
Cheers,
Filip
1 Like