cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti Process Variable value Override by Different Threads

jyotibhushan
Champ on-the-rise
Champ on-the-rise
When we have started the process, The three task has been created using parallel gateway, lets say A, B, C; Now Two user say U1 and U2, perform operation X on Task A and B respectively.

As a part of Operation X, Task A is Completed by User U1, As a result, A service task with expression (named userTimerAction) is executed and after that Task A1 is created.

Similarly, As a part of Operation X, Task B is Completed by User U2, As a result, A service task with expression  (named userTimerAction) is executed and after that Task B1 is created.

The method is same in both the cases

     public void userTimerAction(DelegateExecution execution) {
     }

We do some calculation to calculate  userUri in method userTimerAction and set a process variable in execution as below

      execution.setVariable(WorkflowConstants.USER_URI, userUri);


Some times, If both the Users U1 and U2 perform the operation simultaneously, The value of userUri of one task override the value of Other Task.

it seems to me that since they are setting the value at process level, that why this issue is occurring. if we use method setVariableLocal of delegate execution, it will solve the issue?

Please suggest.

Regards
Jyoti Yadav












3 REPLIES 3

sakumar1
Champ in-the-making
Champ in-the-making
You can pass the variable name WorkflowConstants.USER_URI instead of Constant , define it as a expression in service task.

Regards,
Sakumar

jbarrez
Star Contributor
Star Contributor
setVariableLocal will set the variable on the execution, but at one point you do need to merge them. You could do this later with an execution listener and decide based on the other values you know.

speise
Champ in-the-making
Champ in-the-making

Have the same problem. Did you solve it?