<!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: JBPM5 Starting Guvnor process question
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/npereira">npereira</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/622419#622419">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi forum,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm still having some dificulty with his question, I was wondering if someone could help.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western">What we are trying to implement is a startProcess() method.</p><p class="western">The objective of this method is to contact the runtime engine and &ldquo;tell it&#8221; to start a given process, without using REST.</p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western">So far we have gotten to these point.</p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;">KnowledgeAgentConfiguration aconf = KnowledgeAgentFactory.<em>newKnowledgeAgentConfiguration</em>();</span></p><p class="western"><span style="font-size: 10pt; font-family: monospace;"><span style="color: #000000;"> KnowledgeAgent kagent = KnowledgeAgentFactory.</span><span style="color: #000000;"><em>newKnowledgeAgent</em></span><span style="color: #000000;">(</span><span style="color: #2a00ff;">"testKAgent"</span><span style="color: #000000;">, aconf);&#160;&#160;&#160;&#160; </span></span> </p><p class="western"><span style="font-family: monospace;"><span style="color: #000000;">String fileName = </span><span style="color: #2a00ff;">"/home/n1w3/Downloads/ChangeSet.xml"</span><span style="color: #000000;">;</span></span></p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> kagent.applyChangeSet(ResourceFactory.<em>newFileResource</em>(fileName));</span></p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> KnowledgeBase kbase = kagent.getKnowledgeBase();</span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> </span>&#160;</p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> StatefulKnowledgeSession ksession = kbase.newStatefulKnowledgeSession();</span></p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> Collection&lt;ProcessInstance&gt; c = ksession.getProcessInstances();</span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> </span>&#160;</p><p class="western"><span style="font-size: 10pt; font-family: monospace;"><span style="color: #000000;"> System.</span><span style="color: #0000c0;"><em>out</em></span><span style="color: #000000;">.println(c.size());</span></span></p><p class="western"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> kbase = kagent.getKnowledgeBase();</span></p><p class="western"><span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: monospace;"><span style="color: #7f0055;"><strong>for</strong></span><span style="color: #000000;"> (Process process: kbase.getProcesses()) {</span></span></p><p class="western"><span style="color: #000000;"> <span style="font-family: monospace;"><span style="font-size: 10pt;"> System.</span><span style="color: #0000c0;"><em>out</em></span><span style="color: #000000;">.println(</span><span style="color: #2a00ff;">"Loading process from Guvnor: "</span><span style="color: #000000;"> + process.getId());</span></span></span></p><p class="western"><span style="color: #000000;"> <span style="font-size: 10pt; font-family: monospace;">}</span></span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #000000; font-size: 10pt; font-family: monospace;"> </span>&#160;</p><p class="western"><span style="color: #000000;">&#160; <span style="font-family: monospace;"><span style="font-size: 10pt;">ksession.getWorkItemManager().registerWorkItemHandler(</span><span style="color: #2a00ff;">"Human Task"</span><span style="color: #000000;">, </span><span style="color: #7f0055;"><strong>new</strong></span><span style="color: #000000;"> WSHumanTaskHandler());</span></span></span></p><p class="western"><span style="color: #000000;"> </span><span style="font-size: 10pt; font-family: monospace;"><span style="color: #3f7f5f;">//StatefulKnowledgeSession </span><span style="color: #3f7f5f; text-decoration: underline;">ksession</span><span style="color: #3f7f5f;"> = kbase.newStatefulKnowledgeSession();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; </span></span> </p><p class="western"><span style="color: #000000;"> <span style="font-family: monospace;"><span style="font-size: 10pt;">ProcessInstance processInstance = ksession.startProcess(</span><span style="color: #2a00ff;">"com.temenos.bpmn.CustomerOnBoarding"</span><span style="color: #000000;">);</span></span></span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;"><span style="color: #000000;"> </span> &#160;</p><p class="western"><span style="color: #000000;"> <span style="font-size: 10pt; font-family: monospace;">System.</span></span><span style="color: #0000c0; font-size: 10pt; font-family: monospace;"><em>out</em></span><span style="color: #000000; font-size: 10pt; font-family: monospace;">.println(processInstance.getId());</span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western"><span style="color: #000000; font-size: 12pt; font-family: 'Liberation Serif', serif;">These peace of code, lets us fetch the processes that are in guvnor and then start a new process. </span> </p><p class="western"><span style="color: #000000; font-size: 12pt; font-family: 'Liberation Serif', serif;">The problem with it, is that I have to maintain my session open so that the process gets orchestrated. If I stop the program, the process does not get orchestrated.</span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western"><span style="color: #000000; font-size: 12pt; font-family: 'Liberation Serif', serif;">The objective we are trying to obtain is something like a &ldquo;fire and forget&#8221; approach where we say start process and the runtime engine orchestrates it.</span></p><p class="western" style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p class="western"><span style="color: #000000; font-size: 12pt; font-family: 'Liberation Serif', serif;">Can anybody help us out with this one?</span></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/622419#622419">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>