cancel
Showing results for 
Search instead for 
Did you mean: 

Multi-instance doesn't work in callActivity

ryu
Champ in-the-making
Champ in-the-making
Hi,

In the document of 5.3, it has been said that Multi-instance works with callactivity. The following simple test scenario can invoke callactivity multiple times, but it seems like the result of the sub process couldn't write back to the main process as follows:
9 REPLIES 9

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
ryu,

'does  not work' is kind of unclear… a test can fail for all kinds of reasons. So instead of just pasting a small bpmn snippet, it would be better if you have a real full testcase, bpmn, java unit test etc… e.g. in the form of a maven project

ryu
Champ in-the-making
Champ in-the-making
Hi Ronald,

my bad. I have a very simple test as follows

1. The process takes a list as variable: nameList
List<String> nameList = new ArrayList<String>();
  nameList.add("kermit");
  nameList.add("frozzy");
2. For each elements in the nameList, the main process calls a subprocess as belows

    <callActivity id="callactivity2" name="Call activity" calledElement="loopCallActivitiesSub">
   <multiInstanceLoopCharacteristics isSequential="true"
       activiti:collection="nameList" activiti:elementVariable="thisName">
   </multiInstanceLoopCharacteristics>
   <extensionElements>
           <activiti:in source="thisName" target="name" />
           <activitiSmiley Surprisedut source="name" target="name" />
   </extensionElements>
    </callActivity>
3. subprocess has a scriptTask to modify the input name and write back to the main process
name = "hello_" + name;ERROR:
1. Without multiInstanceLoopCharacteristics, process returns an expected result: the "name" variable was modified by the sub process (callActivity works normally as always)
2. With multiInstanceLoopCharacteristics: returns
org.activiti.engine.ActivitiException: cvc-complex-type.2.4.d: Invalid content was found starting with element 'extensionElements'. No child element is expected at this point. | diagrams/loopCallActivities.bpmn20.xml | line 10 | column 23
so I move the element extensionElements up above the element multiInstanceLoopCharacteristics (but still within callActivity), then the "name" variable wasn't modified by the sub process. I expected: "hello_frozzy"

ryu
Champ in-the-making
Champ in-the-making
when I debugg, the callActivity has been called and its scriptTask is executed for 3 times. But its output never writes back to the main process variable "name".

ryu
Champ in-the-making
Champ in-the-making
And of course, when there are multi subprocess, there are multi outputs back to the main process. Please clarify how Activiti will handle such situation so that output results from sub processes don't overwritten each other.
Please help!

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
And of course, when there are multi subprocess, there are multi outputs back to the main process. Please clarify how Activiti will handle such situation so that output results from sub processes don't overwritten each other.
Please help!

Using different variable names is the only thing I can think of for now

jbarrez
Star Contributor
Star Contributor
Looking at your process, the output variable name for the call activity is always the same, so your result is logical.

As Ronald suggests, using another variables for each of the instances would solve it.

ryu
Champ in-the-making
Champ in-the-making
yes, I tried every way to write the output of each subprocess in different variables of the main process. The question is how. For example:
<activitiSmiley Surprisedut source="thisName" target="name[loopCounter]" />or
<activitiSmiley Surprisedut source="thisName" target="${name[loopCounter]}" />with name is a String array and loopCounter indicates the "index in the for-each loop of that particular instance" (described in the document)
Result: the name array prints null

jaiwo99
Champ in-the-making
Champ in-the-making
i have the same problem, does anybody have an idea XD. Thx… :cry:

i tried this in the subprocess:
${items[loopCounter] == "1"}
org.activiti.engine.impl.javax.el.PropertyNotFoundException: Cannot resolve identifier 'loopCounter'

bzeuner
Champ in-the-making
Champ in-the-making
If it's a multiInstance-callActivity all output parameters will be ignored. Only the class CallActivityBehavior has a routine that handles defined output parameters. The Parallel- and SequentialMultiInstanceBehavior ignore them.
So it is not possible to process several objects within a callActivity and "overwrite" the output parameter