Activiti Timer event and multitenancy issue

cancel
Showing results for 
Search instead for 
Did you mean: 
goce_stojcev
Member II

Activiti Timer event and multitenancy issue

Hi there,

I have process definition that includes timer event. When timer elapse, flow is executing a tasks that executes java code.

Definition of that task includes:

Script Format: groovy

Script: MyClass.MyMethod(execution.getVariable("MY_VARIABLE"))

I am using Single "Engine - Shared Database" multi-tenancy functionality of acitiviti engine, and activity is running as part of java spring web application.

Following is how I build the activity deployment when application is started:

DeploymentBuilder deploymentBuilder =
    repositoryService
        .createDeployment()
        .enableDuplicateFiltering()
        .tenantId(currentTenantResolver.getCurrentTenantId())
        .name(resource.getFilename());

Following is dependency definition in the pom file

<dependency>
    <groupId>org.activiti</groupId>
    <artifactId>activiti-spring</artifactId>
    <version>6.0.0</version>
</dependency>

Following is the definition for the process definition

ProcessDefinition processDefinition =
    repositoryService
        .createProcessDefinitionQuery()
        .processDefinitionKey(SIGNUP_PROCESS_KEY)
        .processDefinitionTenantId(currentTenantResolver.getCurrentTenantId())
        .latestVersion()
        .singleResult();

My issue is that there are situations when engine is executing  MyClass.MyMethod() for tenant different than the tenant that was used when activity was initiated and process definition was created.

I can see in the database that tenant_id is correctly set for the timer job record, as well as in all other connected records.

Can someone share more info about this. Is this expected behavior or some bug, or there is some wrong usage in my code.

Thanks

5 Replies
salaboy
Senior Member

Re: Activiti Timer event and multitenancy issue

Hi there,

can you please specify the version that you are using? 

It sounds like the job executor that is picking up Job is not taking into consideration the tenant Id? It sounds like something that should have been fixed already. 

goce_stojcev
Member II

Re: Activiti Timer event and multitenancy issue

Hi Mauricio,

I am using activiti-spring package version 6.0.

Any idea what is the version where this issue was resolved?

Thanks for helping on this. 

salaboy
Senior Member

Re: Activiti Timer event and multitenancy issue

It might be that it is fixed in the 6.x branch in Github. You might want to try that. 

goce_stojcev
Member II

Re: Activiti Timer event and multitenancy issue

Hi Mauricio,

I have updated activiti-spring package to version "7-201802-EA" (this looks like latest maven package version.

With this version i get error that package "org.activiti.engine.FormService" can not be found.

Do you know if this is something that was replaced or removed?

Thanks

salaboy
Senior Member

Re: Activiti Timer event and multitenancy issue

Yeah a lot of things are changing in 7, so I wouldn't recommend you to use that unless you really know what is included in version 7. 

I would recommend to clone the 6.x branch of the Activiti/Activiti repository, build that and try that.