We&#39;re using 5.2.0 final here.<br><br>What we are also observing is that whenever a process instance reaches a businessruletask node the rule gets fired a number of times equal to the number of instantiated processes even if any of those processes didn&#39;t reach the bussinessruletask node.<br>

<br>Does this means that whenever a businessruletask is reached in any of the current process instance, the rule gets fired for *all* the instances of the process and subsequent businessruletask nodes won&#39;t fire anything?<br>

<br><br><br>2012/2/13 Esteban Aliverti <span dir="ltr">&lt;<a href="mailto:esteban.aliverti@gmail.com">esteban.aliverti@gmail.com</a>&gt;</span><br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

I had some tests working fine in jbpm 5.1 but failing in 5.3 because of this same reason. I&#39;m not sure if this is this is a regression bug or if there is a deliberated change in the behavior.<div>Maybe someone in the jbpm dev team can shed some light here.</div>



<div><br></div><div>Best Regards,  <br clear="all"><br>XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX<br><br>Esteban Aliverti<br>- Developer @ <a href="http://www.plugtree.com" target="_blank">http://www.plugtree.com </a><br>- Blog @ <a href="http://ilesteban.wordpress.com" target="_blank">http://ilesteban.wordpress.com</a><br>




<br><br><div class="gmail_quote">2012/2/13 Alberto R. Galdo <span dir="ltr">&lt;<a href="mailto:argaldo@gmail.com" target="_blank">argaldo@gmail.com</a>&gt;</span><br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">

<div><div class="h5">

<br><span></span>According to the documentation:<br><br><blockquote style="margin:0pt 0pt 0pt 6.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">&quot;Rule constraints do not have direct access to variables defined inside the process. <br>





It is however possible to refer to the current process instance inside a rule constraint, <br>by adding the process instance to the Working Memory and matching for the process instance in your rule constraint. <br>We have added special logic to make sure that a variable processInstance of type WorkflowProcessInstance <br>





will only match to the current process instance and not to other process instances in the Working Memory. <br>Note that you are however responsible yourself to insert the process instance into the session and, <br>possibly, to update it, for example, using Java code or an on-entry or on-exit or explicit action in your process. <br>





The following example of a rule constraint will search for a person with the same name as the value stored in the variable &quot;name&quot; of the process:&quot;<br></blockquote><br><br>This however does not seem to be true.<br>





<br>The first rule is to receive a stream of objects of type MyObject.<br>This rule starts an associated process.<br><br>The second rule will be called by the process (from bpmn).<br><br>Within the process there a task that invokes an an asynchronous service, ie,<br>





an implementation of WorkItemHandler that contains a Thread that will set call <br>manager.completeWorkItem(workItemId,results);<br>when 30s have passed).<br><br>With this setup we can observe what happens when 2 MyObject instances come into the first rule separated by a short period of time (say 5 seconds).<br>





<br>When the first object comes in a process is created and started (with process id=1)<br>The process passes from the start node to the callMyTask node, which invokes the slow WorkItemHandler references by MyTask <br>(which we have previously registered into session.getWorkItemManager() ). <br>





Because the WorkItemHandler has a thread that waits 30s before completing the work item, it just sits there doing nothing (so far everything is ok)<br>and allows the engine to process other events.<br><br>5 seconds later we insert another MyObject into the stream.<br>





The first rule gets fired and created another process (with process id=2).<br>The process passes from the start node to the callMyTask node, which invoke our slow service.<br><br>We have thus two processes running in parallel.<br>





<br>When the first callMyTask node completes, the next node completeTask is invoked.<br><br>The rule &quot;process complete&quot; is matched as it belongs to the rule flow group &quot;Complete task group&quot;.<br><br>At this point we observe that the rule is matched twice spitting out:<br>





<br>    processInstance.id 2<br>    processInstance.id 1<br>.<br>So the rule has matched both process instances that are in working memory and not just the one (with process id 1) <br>that called the &quot;process complete&quot; rule.<br>





<br><br><br>The rule file<br>-------------<br><br>rule &quot;New case&quot;<br>    when    <br>        $myobject : MyObject(processed==false) from entry-point &quot;myobject stream&quot;        <br>    then<br>        ProcessInstance processInstance=kcontext.getKnowledgeRuntime().createProcessInstance(&quot;com.mycompany.process.MyProcess&quot;, parameters);<br>





        insert(processInstance);<br>        kcontext.getKnowledgeRuntime().startProcessInstance(processInstance.getId());<br>        modify ($myobject){<br>            setProcessed(true)<br>        }<br>    end<br>    <br>





rule &quot;process complete&quot;<br>    ruleflow-group &quot;Complete task group&quot;<br>    no-loop true<br>    when<br>        $processInstance: WorkflowProcessInstance()<br>    then<br>        System.out.println(&quot;processInstance.id &quot; + $processInstance.getId());<br>





    end<br>    <br><br>The BPMN xml<br>------------<br>    <br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; <br>&lt;definitions id=&quot;Definition&quot;<br>             targetNamespace=&quot;<a href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a>&quot;<br>





             typeLanguage=&quot;<a href="http://www.java.com/javaTypes" target="_blank">http://www.java.com/javaTypes</a>&quot;<br>             expressionLanguage=&quot;<a href="http://www.mvel.org/2.0" target="_blank">http://www.mvel.org/2.0</a>&quot;<br>





             xmlns=&quot;<a href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a>&quot;<br>             xmlns:xsi=&quot;<a href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a>&quot;<br>





             xsi:schemaLocation=&quot;<a href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a> BPMN20.xsd&quot;<br>             xmlns:g=&quot;<a href="http://www.jboss.org/drools/flow/gpd" target="_blank">http://www.jboss.org/drools/flow/gpd</a>&quot;<br>





             xmlns:bpmndi=&quot;<a href="http://www.omg.org/spec/BPMN/20100524/DI" target="_blank">http://www.omg.org/spec/BPMN/20100524/DI</a>&quot;<br>             xmlns:dc=&quot;<a href="http://www.omg.org/spec/DD/20100524/DC" target="_blank">http://www.omg.org/spec/DD/20100524/DC</a>&quot;<br>





             xmlns:di=&quot;<a href="http://www.omg.org/spec/DD/20100524/DI" target="_blank">http://www.omg.org/spec/DD/20100524/DI</a>&quot;<br>             xmlns:tns=&quot;<a href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a>&quot;&gt;<br>





<br>    &lt;process processType=&quot;Private&quot; isExecutable=&quot;true&quot; id=&quot;com.mycompany.process.MyProcess&quot; name=&quot;my process&quot; &gt;<br><br>        &lt;!-- process variables --&gt;<br>        <br>





        &lt;!-- nodes --&gt;<br>        &lt;startEvent id=&quot;start&quot; name=&quot;StartProcess&quot; /&gt;<br>        <br>        &lt;task id=&quot;callMyTask&quot; name=&quot;call my task&quot; tns:taskName=&quot;MyTask&quot; &gt;<br>





            &lt;ioSpecification&gt;<br>            &lt;/ioSpecification&gt;<br>        &lt;/task&gt;<br>    <br>    <br>        &lt;businessRuleTask id=&quot;completeTask&quot; name=&quot;Complete slow task&quot; g:ruleFlowGroup=&quot;Complete task group&quot; &gt;<br>





        &lt;/businessRuleTask&gt;<br>    <br>        &lt;endEvent id=&quot;end&quot; name=&quot;EndProcess&quot; /&gt;<br><br>        &lt;!-- connections --&gt;<br>        &lt;sequenceFlow id=&quot;start-callMyTask&quot; sourceRef=&quot;start&quot; targetRef=&quot;callMyTask&quot; /&gt;<br>





        &lt;sequenceFlow id=&quot;callMyTask-completeTask&quot; sourceRef=&quot;callMyTask&quot; targetRef=&quot;completeTask&quot; /&gt;<br>        &lt;sequenceFlow id=&quot;completeTask-end&quot; sourceRef=&quot;completeTask&quot; targetRef=&quot;end&quot; /&gt;<br>





    &lt;/process&gt;<br>&lt;/definitions&gt;<br><br><br>What&#39;s wrong with this?  Isn&#39;t WorkflowProcessInstance() supposed to be attached to the calling ProcessInstance?  Is there another way of getting the group of rules fire only for the processinstance that called it?<br>





<br><br clear="all">Greets,<br>
<br></div></div>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br></div>
<br>_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br></blockquote></div><br>