cancel
Showing results for 
Search instead for 
Did you mean: 

Async continuation with subprocess-loop

workflowuser2
Champ in-the-making
Champ in-the-making
Hi Group,

I know that this topic is repeated multiple times here but I still have difficulty understanding why the following case is not working.

- i have a mainprocess + subprocess repeated (multiInstanceLoopCharacteristics)
- main process has 2 java service classes, subprocess also has two java service classes

suprocess: aync="true"
first service task in subprocess: async="true"

see process attached.
I am expecting that each run of subprocess be executed in different thread. However, all is happening in the same (main) thread.

Any guidence appreciated. thanks.

pdt
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlnsSmiley Surprisedmgdc="http://www.omg.org/spec/DD/20100524/DC" xmlnsSmiley Surprisedmgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="mainprocess" name="process1">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="successEndEvent" name="End"></endEvent>

    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="servicetask1" targetRef="servicetask2"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask2" targetRef="subprocess1"></sequenceFlow>
    <sequenceFlow id="flow4" name="" sourceRef="subprocess1" targetRef="successEndEvent"></sequenceFlow>
   
    <serviceTask id="servicetask1" name="Service Task" activiti:class="com.activiti.acme.delegates.ADelegate"></serviceTask>
    <serviceTask id="servicetask2" name="Service Task" activiti:class="com.activiti.acme.delegates.BDelegate"></serviceTask>
    <subProcess id="subprocess1" name="Sub Process" activiti:async="true">
   
      <multiInstanceLoopCharacteristics isSequential="false" activiti:collection="listObj" activiti:elementVariable="assignee"></multiInstanceLoopCharacteristics>
      <startEvent id="startevent2" name="Start"></startEvent>
      <endEvent id="endevent4" name="End"></endEvent>
      <serviceTask id="servicetask3" name="Service Task" activiti:async="true" activiti:class="com.activiti.acme.delegates.Sub1VariableDelegate"></serviceTask>
      <serviceTask id="servicetask5" name="Service Task" activiti:class="com.activiti.acme.delegates.Sub2Delegate"></serviceTask>
     
      <sequenceFlow id="flow9" name="" sourceRef="startevent2" targetRef="servicetask3"></sequenceFlow>
      <sequenceFlow id="flow10" name="" sourceRef="servicetask3" targetRef="servicetask5"></sequenceFlow>
      <sequenceFlow id="flow11" name="" sourceRef="servicetask5" targetRef="endevent4"></sequenceFlow>
    </subProcess>
   
  </process>
</definitions>
4 REPLIES 4

frederikherema1
Star Contributor
Star Contributor
The sequential multi-instance behavior actually "wraps" the existing behavior (in your case, a subprocess) and executes it UNTILL the completionCondition evaluates to true or loop-count reaches it's end. At the time multi-instance was created, there were no async-continuations yet, making the synchronous looping approach valid.

Looks like, when async was added, there was no "special" handling introduced for multi-instance activities. The engine just sees it as ONE activity it needs to execute, with itself creates the parallel-executions which in turn are executed by the same thread. There is no quick fix for that I'm afraid…

workflowuser2
Champ in-the-making
Champ in-the-making
Hi frederikheremans

Thanks for the reply.
"At the time multi-instance was created, there were no async-continuations yet, making the synchronous looping approach valid."
I thought putting "async=true" at subprocess level would trigger async-continuation when multi-instance is created?

Could you suggest a workaround for this?
Is there a JIRA that I can track or do you want me to create a JIRA?

pdt

nbuso
Champ in-the-making
Champ in-the-making
Hi workflowuser2,

did you managed to find a solution at this multi instance, concurrent execution?
I'm still stuck on this:
http://forums.activiti.org/en/viewtopic.php?f=6&t=4834

n.

frederikherema1
Star Contributor
Star Contributor
A workaround could be to make the first service-task in the Multi-instance subprocess to be "async", rather that the multi-instance itself…