REST API & multi tenancy shared definitions

Full disclosure, I have no JAVA ecosystem knowledge at all.

So far I’ve been successfully implementing Camunda processes using the Docker image, Javascript, nodejs and the REST API, no problem at all.

However it looks like I need to use multi tenancy where the tenants can start shared processes and then things start to unravel for me! Looking at the github example at: https://github.com/camunda/camunda-bpm-examples/tree/master/multi-tenancy/tenant-identifier-shared-definitions I get lost at the point where it says “Implement the SPI TenantIdProvider”! How would I even do that with the Docker distibution? Is it possible at all with my limited knowldege of All things JAVA?

Can anyone help me decide if this this is even feasible with my limited skillset before I spend a week or so chasing a goal that’s out of my reach?

Many thanks!

@IanS what are you trying to do? Based on the title: you are trying to have Process Definitions that are available to multiple tenants?

Hi @StephenOTT,

I’d like to enable different tenants to start a process that is available to all of them. The only other way I can see to do this is to upload the same process multiple times with a tenantID. The link I gave seemed like an explanation of how to achieve this but confounded me within the first few sentences!!

Also when a tenant starts their process it must not be visible via the REST API to another tenant.

Create a process that has no tenant id so it is available to all tenants.

In that process have a call activity that calls your actual process and provide the tenant id of that user.

The parent process will act as a gateway to the actual process which will get locked to the tenant

Nice idea! I’ll give it a go, thanks!

Hi @StephenOTT ,

I’ve trawled around the class documentation and can’t easily see how to start a process with tenantId in a script for example:

execution.getProcessEngineServices().getRuntimeService().startProcessInstanceByKey(....)

Doesn’t provide what I need.

Is the name of the process engine actually the tenant id?

Could I call:

execution.getProcessEngineServices().getRuntimeService(tenantId).startProcessInstanceByKey(....)

Do you have any suggestions?

Why are you executing a script? My description above does not use a script. You a call activity which will allow you to set the tenant.

Thanks for the pointer, I have never used a call activity and didn’t read as such in your post!

In the configuration of the call-activity you can use a expression in the tenant field. So you can calculate what tenant to use based on a input mapping and then use the expression in the tenant config to get the value from the mapped local variable/variable from the input mapping.

Many thanks for your help @StephenOTT, it works brilliantly! A very straightforward solution.

@StephenOTT, it seems I spoke too soon… :frowning_face:

I seem to be going round in circles with this and back where I started.

It seems that I cannot start a process for a given tenant if that process is deployed without a tenant. So my previous success was because I had forgotten to delete a previous deployment.

I feel like I’m missing something - any suggestions?

Has anyone implemented this at all as per the op?

Unfortunately I’m still trying to find an answer to this issue :frowning_face:

Is there anyone out there that would work on this for me on a freelance basis maybe?

@IanS,

I am stuck in the same point trying to initiate a shared process from a tenant. Were you able to figure out the issue and make it work?

Apologies for only spotting this nearly 2 years later! But for those still searching, we paid a Java contractor to write the code for this which looks surprisingly simple when you know what you are doing! The main thing to look out for is that if a user who starts a workflow belongs to more than one tenant then an override is needed in order for the correct tenant to be selected. What worked for us is to pass in a variable when starting a workflow which identifies the required tenant.