AnsweredAssumed Answered

Multi-Instance Collection expression called more often than expected

Question asked by jwestra on Feb 26, 2016
I have a simple workflow with a multi-Instance ScriptTask that logs the "element" of the Collection it is working on.  Files to run the test case are attached to the post.

The Multi-Instance ScriptTask looks like this:

<scriptTask id="scripttask1" name="Log Person"  scriptFormat="groovy" activiti:autoStoreVariables="false">
      <multiInstanceLoopCharacteristics isSequential="false"
                import org.kritek.activiti.test.multiInstance.*


                println "ScriptTask logging the Person for this multi-instance: "+person</script>

Expected Behavior
I would expect the engine to call the Collection expression method one time, then divide up the list returned and call as many instances as needed of the ScriptTask.

Behavior my JUnit shows
The junit actually calls the personService.getPeopleByLocation() 9 times!
It only runs 3 instances, which is correct.  But, it ends up invoking the Collection expression  activiti:collection="${peopleService.getPeopleByLocation(location)}" 8 times more than expected.

This behavior would be a performance hindrance in a system with large, expensive lists to iterator over.  It may also end up returning a different list each time it is called depending on the logic of the service call.  Can any body tell me why the multi-Instance is making so many calls?