<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Re: jBPM 5 Loop Type support?
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/byungwoojun">byungwoojun</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/590151#590151">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>First of all, thank you very much for your reply! After your reply (thanks for the inspiration), I modifed my bpmn file, replacing the first converging parallel gateway with the converging "exclusive" gateway. See the attached bpmn file. After the changing, the loop worked!  So, the process has the converging exclusive gateway followed by the diverging exclusive gateway. Now, I think it is obvious.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>BTW, do have a suggestion for my question #1 (Subprocess looptype attribute from the Eclipse BPMN 2 Process Editor)?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks,</p><p>bwj</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/2-590151-11674/loopback2.bmp"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/2-590151-11674/450-151/loopback2.bmp </span></a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>=========================</p><p>processTest2.java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>import java.util.HashMap;<br/>import java.util.Map;<br/>import java.util.Properties;</p><p>import org.drools.KnowledgeBase;<br/>import org.drools.KnowledgeBaseFactory;<br/>import org.drools.builder.KnowledgeBuilder;<br/>import org.drools.builder.KnowledgeBuilderFactory;<br/>import org.drools.builder.ResourceType;<br/>import org.drools.compiler.BPMN2ProcessFactory;<br/>import org.drools.compiler.ProcessBuilderFactory;<br/>import org.drools.impl.EnvironmentFactory;<br/>import org.drools.io.ResourceFactory;<br/>import org.drools.logger.KnowledgeRuntimeLogger;<br/>import org.drools.logger.KnowledgeRuntimeLoggerFactory;<br/>import org.drools.marshalling.impl.ProcessMarshallerFactory;<br/>import org.drools.runtime.KnowledgeSessionConfiguration;<br/>import org.drools.runtime.StatefulKnowledgeSession;<br/>import org.drools.runtime.process.ProcessRuntimeFactory;<br/>import org.jbpm.bpmn2.BPMN2ProcessProviderImpl;<br/>import org.jbpm.marshalling.impl.ProcessMarshallerFactoryServiceImpl;<br/>import org.jbpm.process.builder.ProcessBuilderFactoryServiceImpl;<br/>import org.jbpm.process.instance.ProcessRuntimeFactoryServiceImpl;<br/>import org.jbpm.process.workitem.wsht.WSHumanTaskHandler;</p><p>/**<br/> * This is a sample file to launch a process.<br/> */<br/>public class ProcessTest2 {</p><p> public static final void main(String[] args) {<br/>  try {<br/>   // load up the knowledge base<br/>   KnowledgeBase kbase = readKnowledgeBase();<br/>   StatefulKnowledgeSession ksession = createSession(kbase);<br/>   KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");</p><p>   // start a new process instance<br/>   Map<String, Object> params = new HashMap<String, Object>();<br/>   params.put("count", 1);   <br/>   ksession.startProcess("looptest777", params);<br/>   logger.close();<br/>  } catch (Throwable t) {<br/>   t.printStackTrace();<br/>  }<br/> }</p><p> private static KnowledgeBase readKnowledgeBase() throws Exception {<br/>  ProcessBuilderFactory.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());<br/>  ProcessMarshallerFactory.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());<br/>  ProcessRuntimeFactory.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());<br/>  BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());<br/>  KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br/>  kbuilder.add(ResourceFactory.newClassPathResource("looptest777.bpmn"), ResourceType.BPMN2);<br/>  return kbuilder.newKnowledgeBase();<br/> }<br/> <br/> private static StatefulKnowledgeSession createSession(KnowledgeBase kbase) {<br/>  Properties properties = new Properties();<br/>  properties.put("drools.processInstanceManagerFactory", "org.jbpm.process.instance.impl.DefaultProcessInstanceManagerFactory");<br/>  properties.put("drools.processSignalManagerFactory", "org.jbpm.process.instance.event.DefaultSignalManagerFactory");<br/>  KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);<br/>  return kbase.newStatefulKnowledgeSession(config, EnvironmentFactory.newEnvironment());<br/> }<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>looptest777.bpmn</p><p>================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><span style="font-size: 10pt;"><p align="left"><?<span style="text-decoration: underline;">xml</span> version="1.0" encoding="UTF-8"?> </p></span></p><p align="left"><definitions id="Definition"</p><p align="left"><span>targetNamespace="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"</span></p><p><p><p align="left"><span>typeLanguage="</span><a class="jive-link-external-small" href="http://www.java.com/javaTypes" target="_blank">http://www.java.com/javaTypes</a><span>"</span></p><p align="left"><span>expressionLanguage="</span><a class="jive-link-external-small" href="http://www.mvel.org/2.0" target="_blank">http://www.mvel.org/2.0</a><span>"</span></p></p><p align="left"><span style="text-decoration: underline;">xmlns</span><span>="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span>"</span></p></p><p><p align="left"><span>xmlns:xsi="</span><a class="jive-link-external-small" href="http://www.w3.org/2001/XMLSchema-instance" target="_blank">http://www.w3.org/2001/XMLSchema-instance</a><span>"</span></p><p align="left"><span>xsi:schemaLocation="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/MODEL" target="_blank">http://www.omg.org/spec/BPMN/20100524/MODEL</a><span> BPMN20.</span><span style="text-decoration: underline;">xsd</span>"</p><p align="left"><span>xmlns:g="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools/flow/gpd" target="_blank">http://www.jboss.org/drools/flow/gpd</a><span>"</span></p><p align="left"><span>xmlns:bpmndi="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/BPMN/20100524/DI" target="_blank">http://www.omg.org/spec/BPMN/20100524/DI</a><span>"</span></p></p><p align="left"><span>xmlns:dc="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DC" target="_blank">http://www.omg.org/spec/DD/20100524/DC</a><span>"</span></p><p><p align="left"><span>xmlns:di="</span><a class="jive-link-external-small" href="http://www.omg.org/spec/DD/20100524/DI" target="_blank">http://www.omg.org/spec/DD/20100524/DI</a><span>"</span></p><p align="left"><span>xmlns:tns="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools" target="_blank">http://www.jboss.org/drools</a><span>"></span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><itemDefinition id="_countItem" structureRef="Integer" /></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><process processType="Private" isExecutable="true" id="looptest777" name="looptest777.b" ></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><!-- process variables --></p><p align="left"><property id="count" itemSubjectRef="_countItem"/></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><!-- nodes --></p><p align="left"><startEvent id="_1" name="Start" /></p><p align="left"><scriptTask id="_2" name="Hello" ></p><p align="left"><script>System.out.println("Hello");</p><p align="left"></script></p><p align="left"></scriptTask></p><p align="left"><scriptTask id="_4" name="Hello Again" ></p><p align="left"><script>System.out.println("Hello Again");</script></p><p align="left"></scriptTask></p><p align="left"><exclusiveGateway id="_5" name="Gateway" gatewayDirection="Diverging" /></p><p align="left"><endEvent id="_6" name="End" ></p><p align="left"><terminateEventDefinition/></p><p align="left"></endEvent></p><p align="left"><scriptTask id="_7" name="Hello Back" ></p><p align="left"><script>System.out.println("Hello back");</p><p align="left">count += 1;</p><p align="left">System.out.println("count: " + count);</p><p align="left">kcontext.setVariable("count", count);</p><p align="left"></script></p><p align="left"></scriptTask></p><p align="left"><scriptTask id="_8" name="Hello Post" ></p><p align="left"><script>System.out.println("Hello Post");</script></p><p align="left"></scriptTask></p><p align="left"><exclusiveGateway id="_10" name="Gateway" gatewayDirection="Converging" /></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><!-- connections --></p></p><p align="left"><sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /></p><p align="left"><sequenceFlow id="_10-_4" sourceRef="_10" targetRef="_4" /></p><p><p align="left"><sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5" /></p><p align="left"><sequenceFlow id="_8-_6" sourceRef="_8" targetRef="_6" /></p><p align="left"><sequenceFlow id="_5-_7" sourceRef="_5" targetRef="_7" name="loop back" ></p><p align="left"><conditionExpression xsi:type="tFormalExpression" >return count &lt; 3;</conditionExpression></p><p align="left"></sequenceFlow></p><p align="left"><sequenceFlow id="_5-_8" sourceRef="_5" targetRef="_8" name="otherwise" ></p><p align="left"><span><conditionExpression xsi:type="tFormalExpression" language="</span><a class="jive-link-external-small" href="http://www.jboss.org/drools/rule" target="_blank">http://www.jboss.org/drools/rule</a><span>" ></span><span style="text-decoration: underline;">eval</span>(true)</conditionExpression></p><p align="left"></sequenceFlow></p><p align="left"><sequenceFlow id="_2-_10" sourceRef="_2" targetRef="_10" /></p><p align="left"><sequenceFlow id="_7-_10" sourceRef="_7" targetRef="_10" /></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"></process></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p align="left"><bpmndi:BPMNDiagram></p><p align="left"><bpmndi:BPMNPlane bpmnElement="looptest777" ></p><p align="left"><bpmndi:BPMNShape bpmnElement="_1" ></p><p align="left"><dc:Bounds x="27" y="150" width="48" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_2" ></p><p align="left"><dc:Bounds x="95" y="152" width="80" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_4" ></p><p align="left"><dc:Bounds x="286" y="205" width="80" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_5" ></p><p align="left"><dc:Bounds x="411" y="156" width="48" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_6" ></p><p align="left"><dc:Bounds x="609" y="152" width="48" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_7" ></p><p align="left"><dc:Bounds x="287" y="94" width="80" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_8" ></p><p align="left"><dc:Bounds x="492" y="156" width="80" height="48" /></p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNShape bpmnElement="_10" ></p></p><p align="left"><dc:Bounds x="202" y="149" width="48" height="48" /></p><p><p align="left"></bpmndi:BPMNShape></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_1-_2" ></p><p align="left"><di:waypoint x="51" y="174" /></p><p align="left"><di:waypoint x="135" y="176" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_10-_4" ></p><p align="left"><di:waypoint x="226" y="173" /></p><p align="left"><di:waypoint x="326" y="229" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_4-_5" ></p><p align="left"><di:waypoint x="326" y="229" /></p><p align="left"><di:waypoint x="435" y="180" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_8-_6" ></p><p align="left"><di:waypoint x="532" y="180" /></p><p align="left"><di:waypoint x="633" y="176" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_5-_7" ></p><p align="left"><di:waypoint x="435" y="180" /></p><p align="left"><di:waypoint x="327" y="118" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_5-_8" ></p><p align="left"><di:waypoint x="435" y="180" /></p><p align="left"><di:waypoint x="532" y="180" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_2-_10" ></p><p align="left"><di:waypoint x="135" y="176" /></p><p align="left"><di:waypoint x="226" y="173" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"><bpmndi:BPMNEdge bpmnElement="_7-_10" ></p><p align="left"><di:waypoint x="327" y="118" /></p><p align="left"><di:waypoint x="226" y="173" /></p><p align="left"></bpmndi:BPMNEdge></p><p align="left"></bpmndi:BPMNPlane></p><p align="left"></bpmndi:BPMNDiagram></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p></definitions></p></p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/590151#590151">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>