cancel
Showing results for 
Search instead for 
Did you mean: 

multiInstanceLoopCharacteristics not executed concurrently

akirafei
Champ in-the-making
Champ in-the-making
Hi,

I created a service task with multiInstanceLoopCharacteristics. It is working fine but I found that task instances are executed sequentially not concurrently although I set isSequential="false" .


The task configuration is

<serviceTask id="XXX" name="XXX" activiti:delegateExpression="${xxx}" activiti:exclusive="false">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="xxxList" activiti:elementVariable="xxxRequest"></multiInstanceLoopCharacteristics>
    </serviceTask>

The engine is 5.16.4  .  The project is with spring framework.

   <bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"
      depends-on="dataSource,transactionManager">
      <property name="databaseType" value="h2" />
      <property name="dataSource" ref="dataSource" />
      <property name="transactionManager" ref="transactionManager" />
      <property name="databaseSchemaUpdate" value="create-drop" />
      <property name="jobExecutorActivate" value="false" />   
      <property name="history" value="full" />
      <property name="deploymentResources" value="classpath*:activiti/*.bpmn" />
   </bean>

I tried adding sleep and long loop in task code and the tasks are always executed in sequential.

From log I can see task instances are created at the same time. However, somehow they are executed in order.

13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.b.b.MultiInstanceActivityBehavior - Multi-instance 'Activity(XXXTask)' initialized. Details: loopCounter=0, nrOrCompletedInstances=0,nrOfActiveInstances=4,nrOfInstances=4
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.p.entity.ExecutionEntity - Child execution ScopeExecution[38] created with parent
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.b.b.MultiInstanceActivityBehavior - Multi-instance 'Activity(XXXTask)' initialized. Details: loopCounter=1, nrOrCompletedInstances=0,nrOfActiveInstances=4,nrOfInstances=4
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.p.entity.ExecutionEntity - Child execution ScopeExecution[39] created with parent
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.b.b.MultiInstanceActivityBehavior - Multi-instance 'Activity(XXXTask)' initialized. Details: loopCounter=2, nrOrCompletedInstances=0,nrOfActiveInstances=4,nrOfInstances=4
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.p.entity.ExecutionEntity - Child execution ScopeExecution[40] created with parent
13:01:16.881 [DefaultThreadPool-2] DEBUG o.a.e.i.b.b.MultiInstanceActivityBehavior - Multi-instance 'Activity(XXXTask)' initialized. Details: loopCounter=3, nrOrCompletedInstances=0,nrOfActiveInstances=4,nrOfInstances=4


Is there any high level configuration in engine needs to set?   Can someone please help? Thanks.




4 REPLIES 4

akirafei
Champ in-the-making
Champ in-the-making
The task configuration is
<serviceTask id="XXXTask" name="XXXTask" activiti:delegateExpression="${XXXTask}" activiti:exclusive="false">
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="xxxRequestList" activiti:elementVariable="xxxRequest"></multiInstanceLoopCharacteristics>
    </serviceTask>


The engine configuration:
<bean id="processEngineConfiguration" class="org.activiti.spring.SpringProcessEngineConfiguration"
  depends-on="dataSource,transactionManager">
  <property name="databaseType" value="h2" />
  <property name="dataSource" ref="dataSource" />
  <property name="transactionManager" ref="transactionManager" />
  <property name="databaseSchemaUpdate" value="create-drop" />
  <property name="jobExecutorActivate" value="false" />
  <property name="history" value="full" />
  <property name="deploymentResources" value="classpath*:activiti/*.bpmn" />
</bean>

<bean id="processEngine" class="org.activiti.spring.ProcessEngineFactoryBean"
  depends-on="processEngineConfiguration">
  <property name="processEngineConfiguration" ref="processEngineConfiguration" />
</bean>

ollib
Champ in-the-making
Champ in-the-making
Tasks are always executed in some sequential order. Tasks in an multi instance construct are no exeception to this rule. Think of 10 user tasks that are started as multi instance tasks. Each task is started (one after the other) and then blocks, because it needs a user decision. So you have 10 active tasks. Now think of 10 user tasks that are executed sequentially. In this case you would only have 1 active user task at a time.

akirafei
Champ in-the-making
Champ in-the-making
Thanks ollib for the reply.    Then what does the property is_Sequential mean? 

My goal is to have parallel executed multi instance pattern since they do not have dependencies and performance is critical to me. Is there any solution in activiti?

Thanks.



ollib
Champ in-the-making
Champ in-the-making
I don't think that a workflow system is the best choice if you are really after realtime concurrency. Parallel vs sequential is more a concept. Two tasks a and b are sequential if b cannot be started until a has ended. Two tasks a and b are parallel if they can be started independently from each other. This doesn't mean that they start exactly at the same time technically.