<!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!&#160; 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;">&#160;</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;">&#160;</p><p>Thanks,</p><p>bwj</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>=========================</p><p>processTest2.java</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</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/>&#160; try {<br/>&#160;&#160; // load up the knowledge base<br/>&#160;&#160; KnowledgeBase kbase = readKnowledgeBase();<br/>&#160;&#160; StatefulKnowledgeSession ksession = createSession(kbase);<br/>&#160;&#160; KnowledgeRuntimeLogger logger = KnowledgeRuntimeLoggerFactory.newFileLogger(ksession, "test");</p><p>&#160;&#160; // start a new process instance<br/>&#160;&#160; Map&lt;String, Object&gt; params = new HashMap&lt;String, Object&gt;();<br/>&#160;&#160; params.put("count", 1);&#160;&#160; <br/>&#160;&#160; ksession.startProcess("looptest777", params);<br/>&#160;&#160; logger.close();<br/>&#160; } catch (Throwable t) {<br/>&#160;&#160; t.printStackTrace();<br/>&#160; }<br/> }</p><p> private static KnowledgeBase readKnowledgeBase() throws Exception {<br/>&#160; ProcessBuilderFactory.setProcessBuilderFactoryService(new ProcessBuilderFactoryServiceImpl());<br/>&#160; ProcessMarshallerFactory.setProcessMarshallerFactoryService(new ProcessMarshallerFactoryServiceImpl());<br/>&#160; ProcessRuntimeFactory.setProcessRuntimeFactoryService(new ProcessRuntimeFactoryServiceImpl());<br/>&#160; BPMN2ProcessFactory.setBPMN2ProcessProvider(new BPMN2ProcessProviderImpl());<br/>&#160; KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();<br/>&#160; kbuilder.add(ResourceFactory.newClassPathResource("looptest777.bpmn"), ResourceType.BPMN2);<br/>&#160; return kbuilder.newKnowledgeBase();<br/> }<br/> <br/> private static StatefulKnowledgeSession createSession(KnowledgeBase kbase) {<br/>&#160; Properties properties = new Properties();<br/>&#160; properties.put("drools.processInstanceManagerFactory", "org.jbpm.process.instance.impl.DefaultProcessInstanceManagerFactory");<br/>&#160; properties.put("drools.processSignalManagerFactory", "org.jbpm.process.instance.event.DefaultSignalManagerFactory");<br/>&#160; KnowledgeSessionConfiguration config = KnowledgeBaseFactory.newKnowledgeSessionConfiguration(properties);<br/>&#160; return kbase.newStatefulKnowledgeSession(config, EnvironmentFactory.newEnvironment());<br/> }<br/>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>looptest777.bpmn</p><p>================</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><span style="font-size: 10pt;"><p align="left">&lt;?<span style="text-decoration: underline;">xml</span> version="1.0" encoding="UTF-8"?&gt; </p></span></p><p align="left">&lt;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>"&gt;</span></p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;itemDefinition id="_countItem" structureRef="Integer" /&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;process processType="Private" isExecutable="true" id="looptest777" name="looptest777.b" &gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;!-- process variables --&gt;</p><p align="left">&lt;property id="count" itemSubjectRef="_countItem"/&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;!-- nodes --&gt;</p><p align="left">&lt;startEvent id="_1" name="Start" /&gt;</p><p align="left">&lt;scriptTask id="_2" name="Hello" &gt;</p><p align="left">&lt;script&gt;System.out.println("Hello");</p><p align="left">&lt;/script&gt;</p><p align="left">&lt;/scriptTask&gt;</p><p align="left">&lt;scriptTask id="_4" name="Hello Again" &gt;</p><p align="left">&lt;script&gt;System.out.println("Hello Again");&lt;/script&gt;</p><p align="left">&lt;/scriptTask&gt;</p><p align="left">&lt;exclusiveGateway id="_5" name="Gateway" gatewayDirection="Diverging" /&gt;</p><p align="left">&lt;endEvent id="_6" name="End" &gt;</p><p align="left">&lt;terminateEventDefinition/&gt;</p><p align="left">&lt;/endEvent&gt;</p><p align="left">&lt;scriptTask id="_7" name="Hello Back" &gt;</p><p align="left">&lt;script&gt;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">&lt;/script&gt;</p><p align="left">&lt;/scriptTask&gt;</p><p align="left">&lt;scriptTask id="_8" name="Hello Post" &gt;</p><p align="left">&lt;script&gt;System.out.println("Hello Post");&lt;/script&gt;</p><p align="left">&lt;/scriptTask&gt;</p><p align="left">&lt;exclusiveGateway id="_10" name="Gateway" gatewayDirection="Converging" /&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;!-- connections --&gt;</p></p><p align="left">&lt;sequenceFlow id="_1-_2" sourceRef="_1" targetRef="_2" /&gt;</p><p align="left">&lt;sequenceFlow id="_10-_4" sourceRef="_10" targetRef="_4" /&gt;</p><p><p align="left">&lt;sequenceFlow id="_4-_5" sourceRef="_4" targetRef="_5" /&gt;</p><p align="left">&lt;sequenceFlow id="_8-_6" sourceRef="_8" targetRef="_6" /&gt;</p><p align="left">&lt;sequenceFlow id="_5-_7" sourceRef="_5" targetRef="_7" name="loop back" &gt;</p><p align="left">&lt;conditionExpression xsi:type="tFormalExpression" &gt;return count &amp;lt; 3;&lt;/conditionExpression&gt;</p><p align="left">&lt;/sequenceFlow&gt;</p><p align="left">&lt;sequenceFlow id="_5-_8" sourceRef="_5" targetRef="_8" name="otherwise" &gt;</p><p align="left"><span>&lt;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>" &gt;</span><span style="text-decoration: underline;">eval</span>(true)&lt;/conditionExpression&gt;</p><p align="left">&lt;/sequenceFlow&gt;</p><p align="left">&lt;sequenceFlow id="_2-_10" sourceRef="_2" targetRef="_10" /&gt;</p><p align="left">&lt;sequenceFlow id="_7-_10" sourceRef="_7" targetRef="_10" /&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;/process&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p align="left">&lt;bpmndi:BPMNDiagram&gt;</p><p align="left">&lt;bpmndi:BPMNPlane bpmnElement="looptest777" &gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_1" &gt;</p><p align="left">&lt;dc:Bounds x="27" y="150" width="48" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_2" &gt;</p><p align="left">&lt;dc:Bounds x="95" y="152" width="80" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_4" &gt;</p><p align="left">&lt;dc:Bounds x="286" y="205" width="80" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_5" &gt;</p><p align="left">&lt;dc:Bounds x="411" y="156" width="48" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_6" &gt;</p><p align="left">&lt;dc:Bounds x="609" y="152" width="48" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_7" &gt;</p><p align="left">&lt;dc:Bounds x="287" y="94" width="80" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_8" &gt;</p><p align="left">&lt;dc:Bounds x="492" y="156" width="80" height="48" /&gt;</p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNShape bpmnElement="_10" &gt;</p></p><p align="left">&lt;dc:Bounds x="202" y="149" width="48" height="48" /&gt;</p><p><p align="left">&lt;/bpmndi:BPMNShape&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_1-_2" &gt;</p><p align="left">&lt;di:waypoint x="51" y="174" /&gt;</p><p align="left">&lt;di:waypoint x="135" y="176" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_10-_4" &gt;</p><p align="left">&lt;di:waypoint x="226" y="173" /&gt;</p><p align="left">&lt;di:waypoint x="326" y="229" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_4-_5" &gt;</p><p align="left">&lt;di:waypoint x="326" y="229" /&gt;</p><p align="left">&lt;di:waypoint x="435" y="180" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_8-_6" &gt;</p><p align="left">&lt;di:waypoint x="532" y="180" /&gt;</p><p align="left">&lt;di:waypoint x="633" y="176" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_5-_7" &gt;</p><p align="left">&lt;di:waypoint x="435" y="180" /&gt;</p><p align="left">&lt;di:waypoint x="327" y="118" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_5-_8" &gt;</p><p align="left">&lt;di:waypoint x="435" y="180" /&gt;</p><p align="left">&lt;di:waypoint x="532" y="180" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_2-_10" &gt;</p><p align="left">&lt;di:waypoint x="135" y="176" /&gt;</p><p align="left">&lt;di:waypoint x="226" y="173" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;bpmndi:BPMNEdge bpmnElement="_7-_10" &gt;</p><p align="left">&lt;di:waypoint x="327" y="118" /&gt;</p><p align="left">&lt;di:waypoint x="226" y="173" /&gt;</p><p align="left">&lt;/bpmndi:BPMNEdge&gt;</p><p align="left">&lt;/bpmndi:BPMNPlane&gt;</p><p align="left">&lt;/bpmndi:BPMNDiagram&gt;</p><p align="left" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>&lt;/definitions&gt;</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>