strange multi instance activity behaviour

cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
navitect
Active Member

strange multi instance activity behaviour

Jump to solution

I'm noticing some strange behaviour with multi instance process.

My original need was to create a multi instance call activity, as follows:

<callActivity id="callactivity1" name="Call activity" calledElement="testCalledProcess">
   <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${myList.getList()}" activiti:elementVariable="myVar"></multiInstanceLoopCharacteristics>
</callActivity>

When I try to lookup the process variable myVar in the sub-process I can't find it.

Also, I saw that myList.getList() is being run multiple times. The list has only two entries in it, but from a println in getList() it seems to be run about six times! The correct number of sub-processes (2) is created.

I therefore tried a test with a script task

<scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript" activiti:autoStoreVariables="false">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${myList.getList()}" activiti:elementVariable="myLetter"></multiInstanceLoopCharacteristics>
<script>java.lang.System.out.println("Letter "+myLetter)</script>
</scriptTask>

I found the same behaviour with multiple executions of getList(). i.e. six times. However the variable myLetter is passed and correctly printed correctly. Only two instances of the task are created.

1 Solution

Accepted Solutions
navitect
Active Member

Re: strange multi instance activity behaviour

Jump to solution

I've fixed the problem with not finding the variable in called activity. I'd hadn't mapped the elementVariable in the input parameters.

It's still strange that the service to create the collection seems to run multiple times.

2 Replies
navitect
Active Member

Re: strange multi instance activity behaviour

Jump to solution

I've fixed the problem with not finding the variable in called activity. I'd hadn't mapped the elementVariable in the input parameters.

It's still strange that the service to create the collection seems to run multiple times.

pault
Active Member II

Re: strange multi instance activity behaviour

Jump to solution

The running multiple times may be transaction roll back and retries. I've just been working on a similar problem where I haven't set process variables correctly. I just see my service task run and fail 3 times 10 seconds apart. I assume a rollback is occurring then the transaction is retried. No error is shown presumably as the exception isn't caught.

In your case you have 2 sub processes, so it could be the same behaviour, if each fails and retries 3 times that gives 6.