My application has an unknown number (potentially very large) of tenants, and I want to be able to run each process instance using a tenantId. However, I do not want to deploy each process for each and every tenant (seems illogical - the process definition should be shareable in my use case). How can I start a process from a process definition that has no tenant specified, but apply a tenant ID to the process instance? Is this even possible? When I try to start a process and provide a tenant ID, it seems to be trying to find a process definition that also has that tenant ID, which isn’t what I want. When I go hunting in the ProcessInstanceHelper, it looks like the process of creating a new instance just pulls the tenantId from the process definition. If the answer is that it can’t be done, it seems like my only options are:
- Deploy a tenanted version of each process definition on-demand (programmatically) as each tenant first tries to use it. Seems like performance (on first use) would suffer though, and I’d end up with a DB polluted with hundreds (or thousands) of deployments of each process, all of them identical except for the tenant ID. I think this would work, but it would be super ugly.
- Avoid the use of tenantId completely, and instead maintain some other variable (replicating tenant id) explicitly against the process instance and ensure that I always use that variable when querying for process instances. This seems error prone and presumably would cause problems with things like isolation of signals within the scope of a tenant.
Any good solutions to this problem much appreciated! Ideally I could somehow plug in to the instance creation process to provide my own tenant ID, regardless of what is on the process definition.