Currently I have a sub-process which uses fork/join mechanism to create parallel flows. Lest assume that there are two flows: A, B. Each of that flows takes as input variables complex object CONTEXT. Also each of that flows make some calculation and updates CONTEXT inside. As a output each of flows return updated CONTEXT. The problem here is that in Join point, last result of CONTEXT overrides previous one. Lets assume that flow A fill be finished first with result CONTEXT_1 and flow B will return CONTEXT_2. So final result will be CONTEXT_2 and all changes from flow A will be lost.
The question here is - how to merge results from two flows?
UPDATE: From my observations passed variable (CONTEXT) from SuperProcess to SubProcess are copied(CONTEXT') and after subProcess is finished, new value of passed variable(CONTEXT') will take place of original (CONTEXT).
In the example below I mean that all passed variables have the same name.
Example:
- SuperProcess P1 (Variable: CONTEXT) calls SubProcess P2(variables are passed by copy);
SubProcess P2 (Variable: CONTEXT') creates two parallel flows(Tasks) A, B(variables are passed by copy);
A Task (Variable: CONTEXT_1) updates value of variable, finishes execution and returns variable;
3.1. CONTEXT_1 takes place of variable CONTEXT' so P2 can see only this new value as names of this variables the same;
Meanwhile B Task (Variable: CONTEXT_2) is still working and after some time updates variable, finishes execution and returns variable;
4.1. CONTEXT_2 takes place of variable CONTEXT_1 so P2 can see only this new value as names of this variables the same;
- SubProcess P2 (Variable: CONTEXT_2) finish the execution and returns new veriable to SuperProcess. Result -> CONTEXT_1 is lossed.
My aim scenario:
- SuperProcess P1 (Variable: CONTEXT) calls SubProcess P2(variables are passed by copy);
SubProcess P2 (Variable: CONTEXT') creates two parallel flows(Tasks) A, B(variables are passed by copy);
A Task (Variable: CONTEXT_1) updates value of variable, finishes execution and returns variable;
3.1. CONTEXT_1 and CONTEXT are merged into CONTEXT_M1, in other words, only new changes of CONTEXT_1 will be applied to CONTEXT.
Meanwhile B Task (Variable: CONTEXT_2) is still working and after some time updates variable, finishes execution and returns variable;
4.1. CONTEXT_2 and CONTEXT_M1 are merged into CONTEXT_M2, in other words, only new changes of CONTEXT_2 will be applied to CONTEXT_M1 so previous update will be not lost;
- SubProcess P2 (Variable: CONTEXT_M2) finish the execution and returns new veriable to SuperProcess. Result -> CONTEXT_M2. All changes are saved.