AnsweredAssumed Answered

problems about execution query in multiinstance subprocess

Question asked by dalong on Aug 19, 2014
Latest reply on Aug 19, 2014 by jbarrez
   i design a process with activiti like this below,  we uses activiti by activiti-rest api.
[img=640x400]http://v1.freep.cn/3tb_140819113837fq1p512293.png[/img]

subprocess multiinstance is defined like this:  ( slist = [1,2,3] )
<code lang="xml" linenumbers="normal">
<multiInstanceLoopCharacteristics isSequential="false" activiti:collection="slist" activiti:elementVariable="sid" />
</code>

<h1>I prefered</h1>
here , we have a intermediacatchingevent in multiinstance subprocess. 
<code lang="xml" linenumbers="normal">
<intermediateCatchEvent id="sid-33B4590B-6209-4049-AD12-9D0F847980FA">
    <messageEventDefinition messageRef="testMsg" />
</intermediateCatchEvent>
</code>
now, intermediacatchingevent is trigger by activiti-rest api from other system.  but first i must query this execution in specified instance with sid = 2
but it will take at least two step to find this execution .  first find this subprocess execution(n1) with sid = 2, then find execution with parent id (n1) and subscriptmessage event testMsg.   Very complicated!

<h1>effective approach</h1>
intermediateCatchEvent  can be replace by a user task. like this:
<code lang="xml" linenumbers="normal">
<userTask id="wait_result" name="${sid}-wait_result" activiti:exclusive="false" activiti:assignee="kermit">
    <documentation></documentation>
</userTask>
</code>
attention :  name="${sid}-wait_result"

this is more efficient, because we can find this user task execution by taskName:
taskService.createTaskQuery().taskName("2-wait_result")

<h1>question:</h1>
1. is there a efficent way to find a intermediateCatchEvent execution in multiinstance subprocess,  for example by name through activiti-rest api ( I didn't find it)?
   I know that execution is stored in databases  as tree structure, so i just query db myself ?  or else that official supported method
2. i think usertask is used for triggered by human being,  intermediateCatchEvent  is more appropriate in this case that should be triggered by system.  but complicated query is a big problem especially in multiinstance subprocess.  Is there some advice ?

ps: i use activiti-5.15.1
thanks!

Outcomes