Open pleft opened 3 years ago
It seems that in case we are inside a method that uses as parameter DelegateExecution
(e.g. a JavaDelegate
class or an activiti:expression
method) which derives from a concurrent execution like the one from the timer in the example above, we should only use the DelegateExecution
object to set variables, any call to RuntimeService.setVariableLocal
or TaskService.setVariableLocal
will cause the integrity constraint exception upon task.complete
is called.
In case of setting a task variable then it should be done in a TaskListener.notify
method where DelegateTask
object is available and set the variables on it, e.g.
delegateTask.setVariableLocal("taskLocalVar", "taskLocalVarValue");
Can somebody elaborate on the above? Why and how this changed from version 5.15
? Where in the guide are these restrictions outlined?
can you please create a unit test that reproduces the issue with Activiti 7? former versions are in maintenance mode and we only accept PRs
What is the suggested way to add variables before completing a user task as any call to any call to RuntimeService.setVariableLocal
or TaskService.setVariableLocal
will cause the integrity constraint exception when task.complete
is called.
可以尝试一下修改外键约束为 cascade
Please consider the following diagram
MyProcess.bpmn
To describe it in words, there is one user task (Evaluation) and a timer attached to it (configured to trigger in 2 seconds). Upon triggering the timer, the Timed Autocomplete async service task in its Java Delegate, TimerService, tries to complete the user task (Evaluation) and the flow ends.
TimerService.java
Prior completing the task please notice the line
It just adds a local task variable. After this, the task gets completed by calling:
This results to SQL exception to be thrown:
Similar exception arises if we change the task variable not being local e.g.:
The same code executes successfully with activiti version 5.15.
A sample project can be found at: https://github.com/pleft/DemoActiviti just checkout the constraint_violation branch. It uses activiti version 5.22.0
What's the reason behind this exception? Shouldn't we set this way task variables (from the timer execution)? What has changed from 5.15 to 5.17 and causes this behavior?
Many thanks for your time.