cancel
Showing results for 
Search instead for 
Did you mean: 

Parallel branches (or even multi-instances) and collision of variables.

esseti
Champ in-the-making
Champ in-the-making
Hi all.
i'm developing some new task in java, and right now i'm stuck with a problem.
basically,i've a java task that makes a call, and after this a receiver that receives (as a message) the result of the call.
Basically i call the
/signal/
api passing also a parameter called
results
.
this variable is automatically stored into the process variables and other tasks can access it.
If the process is a sequence of task this works perfectly.
like in this case
[img]https://dl.dropboxusercontent.com/u/4628172/single.png[/img]

but, what if i've a two (or more) parallel branch?
like this?

[img]https://dl.dropboxusercontent.com/u/4628172/parallel.png[/img]

the first both receives results, so one overwrites the other one. right?

is it the same in the multiple-instnace case?

if i implement my Java Task, is there any way to know if it's the only one branch running or if it is in parallel with other branches?

thanks
7 REPLIES 7

jbarrez
Star Contributor
Star Contributor
Variables can be set on the execution local (ie not on process instance scope). That is indeed how you should do it when using multi instance.

esseti
Champ in-the-making
Champ in-the-making
thanks for the reply.
can you point some references or something that explain what you mean with execution local and how to implement it?
thanks

frederikherema1
Star Contributor
Star Contributor
You have 2 sets of methods on DelegateExecution and RuntimeService (similarly for DelegateTask and TaskSevrice):
  • setVariable(…) and setVariables(…): If the variable with the given name is already set in the local scope, the variable is overridden. If not, the parent scope is consulted. If the parent has this variable locally, it's set, otherwise this process continues until the root-execution is reached or the variable is defined on a scope in between. If the variable reached the top-most parent, it's set there.
  • setVariableLocal(..) and setVariablesLocal(…): Set's the variable in the local scope. Parent executions (and siblings) are not affected. Child-scopes can access there local-variables of a parent (using getVariables()).

esseti
Champ in-the-making
Champ in-the-making
ohh thanks.
but in my case of the parallel branches, if i use setVariableLocal() will it keep the variables separated in the two branches? or what?
basically, in the second example, is the scope set to the branch or to the process?

jbarrez
Star Contributor
Star Contributor
If you call setVariableLocal, yes, it will be separated in two branches.

esseti
Champ in-the-making
Champ in-the-making
thanks.
one (hopefully) last question: what does the receive message implements? setLocalVariables or setVariables?

jbarrez
Star Contributor
Star Contributor
I have to check the code, but i believe setVariables.

Might be a good addition to the API to allow to set locals. If you need it, please file a Jira issue so we and you can track it.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.