cancel
Showing results for 
Search instead for 
Did you mean: 

Newbie multitenancy questions

lossril
Champ in-the-making
Champ in-the-making
Hello,
I've read about multitenancy in Activiti and have some questions about it.
Okay, for example we might have two Activiti REST webapps connected to the same database where processes with two different tenantIDs are deployed.
1. How does webapp identify itself with tenantID? I didn't find anything in userguide which would point me where can I configure it. Or do I get the whole point of multitenancy incorrectly? From my point of view multitenancy is the state where two Activiti process engines use the same database but work only with processes which have the tenantID of the process engine.
2. Let's take we have two processes - one for tenantA, one for tenantB - both are started by the same message or signal. This message or signal happens in both process engines simultaneously. Do engines start only the process which is marked by correct tenant? What will happen if some process without tenantID is started by the same message/signal? Will both engines start it, or none?
3. Basically the same question for timed process instance creation.
I'm quite confused about it. If someone could explain it to me, would be awesome. Thanks in advance.
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
1. When you use multitenancy, you always need to pass the tenantId. How you get this tenantId from your current user, that is up to you.

2. Again, you will need to provide the tenantId. There is a non-MT method, and a MT-enabled methode, like   void signalEventReceivedWithTenantId(String signalName, String tenantId);

3. Same. The timer is created in the context of a tenant, when you deployed the process definition.

lossril
Champ in-the-making
Champ in-the-making
Well, I still don't get the idea how the Activiti ProcessEngine gets its own tenantID and starts only those processes which have the correct tenantID.

For example, I create the deployment with the process starting by timer, it would have some tenantID 'rest1'. We have two(or more) REST webapps or any other ProcessEngine instances poking the same database. So what happens when the time comes for process to start? Which ProcessEngine would create the process instance? Would they create several process instances?

I got the point about signals having their tenantIDs though, so when signal arrives(e.g. via REST), it triggers only for the process instances which have the tenantID.

lossril
Champ in-the-making
Champ in-the-making
Well, can someone explain it to me?

jbarrez
Star Contributor
Star Contributor
Relax, this is an open source forum, we try to answer in a best effort way, but many people are on holiday now.

> I still don't get the idea how the Activiti ProcessEngine gets its own tenantID and starts only those processes which have the correct tenantID.

You deploy a certain process definition and provide a tenant id. All process instances derived from this process definition inherit this tenant id. Note that you pass the tenantId when calling the runtimeService.startProcessInstanceByKey() for example.

For your example: the process definition was deployed with a certain tenantId. The timer inherited that tenantId. The process instance that is started will inherit the same tenantId.

lossril
Champ in-the-making
Champ in-the-making
Yes, sure, sorry. I've just bumped the thread so it wouldn't be buried.

Okay, this makes a bit more sense now, thanks a lot!

jwestra
Champ in-the-making
Champ in-the-making
Hi!

I'm not sure the OP's question #2 was ever answered regarding signals that are tenant-aware…  I TOO have the same question Smiley Happy

I am looking at the 5.19.0.2 API's :

RuntimeService.signal(String executionId)
RuntimeService.signal(String executionId, Map<String, Object> processVariables)

Neither of them pass the tenantId. 

Is there a different way to pass a tenantId via a Signal that I am missing, perhaps as a special, reserved processVariable key?

Jason

jbarrez
Star Contributor
Star Contributor
No, and neither should pass the tenant id. signal is executionId bound. execution ids are unique accross tenants.

You're confusing it with signalEventReceived (the BPMN signal), which does have it: signalEventReceivedWithTenantId().

jwestra
Champ in-the-making
Champ in-the-making
Hah.  So many ids and keys to keep track of in my head… Smiley Happy  That makes perfect sense.  Thanks!