AnsweredAssumed Answered

Doubt about the execution of a multi instance task

Question asked by ebbinvarghese on Oct 30, 2015
Latest reply on Nov 3, 2015 by ebbinvarghese
Hi,

The activiti version is 5.18
My application is in PHP and I use activiti-rest.

I have the following multi instance task in a process.

<userTask id="panel_member_evaluation_1" name="Panel  Member Evaluation" activiti:assignee="${assignee}">
      <documentation>Task denoting the evaluation performed by the panel members</documentation>
      <extensionElements>
        <activiti:executionListener event="start" expression="${partnerAssessment.setWorkflowStatus(execution, 3, 'General Assessment In Progress')}"></activiti:executionListener>
        <activiti:taskListener event="create" expression="${partnerAssessment.setPanelMemberWorklist(task , 1)}"></activiti:taskListener>
      </extensionElements>
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="${partnerAssessment.assignPanelMembers(execution, 1)}"                                               activiti:elementVariable="assignee">
        <completionCondition>${nrOfCompletedInstances/nrOfInstances == 1 }</completionCondition>
      </multiInstanceLoopCharacteristics>
</userTask>

I use the activiti:collection attribute to invoke the method assignPanelMembers( ) which will fetch the list of assignees from the PHP application via a REST call.

Some additional operations are carried out by using the task and execution listeners.

I understand that for a multi instance task the execution listener on start will be called n + 1 times where n is no of users in the collection.
In my trial this was 1, so the listener was executed 2 times.

However I observed that the method assignPanelMembers( ) of the activiti:collection is getting called 3 times.
Is this normal ? I expected it to be executed only once during the creation of the multi instance task.
I had written some data initialization code along with the code to fetch the assignee list inside the assignPanelMembers( ) which is now executing multiple times.

Is there a way to invoke a method of a bean which will be invoked only once for this multi instance task ?
If there is , then is it possible to pass the execution inside it's expression like in an execution/task listener ?

Thanks in advance.
Ebbin



Outcomes