cancel
Showing results for 
Search instead for 
Did you mean: 

ActivityExecution flush a variable immediately

mpriess
Champ in-the-making
Champ in-the-making
Hello,

I extended the class TaskActivitiyBehavior to write a own task.

In the method "public void execute(ActivityExecution execution)" I changed a variable and started a new thread which should access the the changed variable.

execution.getVariable("A");

Change the variable from 0 to 1;

execution.setVariable("A", 1);

startNewProcessInAnotherThread();

If I try to access the variable from the new launched process the value is 0. How can I flush the value immediately?






7 REPLIES 7

trademak
Star Contributor
Star Contributor
You can't because the database connection is managed by the Activiti Engine and an execution tree is persisted to the database after it reaches a wait state.

Best regards,

mpriess
Champ in-the-making
Champ in-the-making
Can I use the runtime service in my class to persiste the values earlier?

jbarrez
Star Contributor
Star Contributor
Not really, cause the process instance won't exist yet (it's also flushed at the end).

What is the use case you're trying to solve here?

mpriess
Champ in-the-making
Champ in-the-making
I have a task which launch 1..n new process instances depending on the configuration which is passed to the parent task.  If one of my new processes fail the parent task should be stopped. I also use the parent process actually to save the state and the configuration in a object. This informations are used for visualisation.

jbarrez
Star Contributor
Star Contributor
Can't you use a call activity in a multi instance for this?

mpriess
Champ in-the-making
Champ in-the-making
Do you have a example for a multi instance activiti?

jbarrez
Star Contributor
Star Contributor
I do. As does the documentation and our unit tests ….