<!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;">
    Signal a wait state and suspend related running subprocesses
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/festano1">Stefano Cancedda</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/563527#563527">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Hi All,</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I'm trying to realize a complex use case with Jbpm 4, and I'm lookin for some advises and answers.</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">My requisites are to implements some kind of "phases" inside a business process (which models an authorization issuing system </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">for a governative trade organization) that can be "modular" and pluggable to the basis of some normative &amp; legal factors.</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">I've move to the use of sub-processes in order to implement this, using a dynamic el expression to decide in runtime what process definition of </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">instantiate as sub-process, via parameterizing the jpdl sub-process' key attribute. </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">So the structure is composed by a main process, that groups these phases, and many other subprocesses which can can be </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">authored by external system and business designers.</div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"> </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Another requisite is that in one phase (es: when an integration request is started) the main process is paused, </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">a timer is started (the pause cannot be longer than a business value, and users must be notified if the suspension is reaching it's limit), </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">and then resumed. </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">For authoring sub-process I don't find seamless to design for any subprocess some kind of a "suspension" state </div><div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">(this would be always present, and redundant), so I'm thinking to enforce the suspension state at the level of the main process:</div><div> </div><p>Hi All,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm trying to realize a complex use case with Jbpm 4, and I'm lookin for some advises and answers.</p><p>My requisites are to implements some kind of "<em>phases</em>" inside a business process (which models an authorization issuing system for a governative trade organization) that must be "modular" and <em>pluggable</em> to the basis of some normative &amp; legal factors.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I've move to the use of sub-processes in order to implement this, using a dynamic <em>el expression</em> to decide in runtime what process definition of&#160; instantiate as sub-process, via parameterizing the jpdl sub-process' key attribute. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So the structure is composed by a main process, that groups these phases, and many other subprocesses which can can be </p><p>authored by external system and business designers.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Another requisite is that in one phase (es: when an integration request is started) the main process is paused, </p><p>a timer is started (the pause cannot be longer than a business value, and users must be notified if the suspension is reaching it's limit), </p><p>and then resumed. </p><p>For authoring sub-process I don't find seamless to design for any subprocess some kind of a "suspension" state </p><p>(this would be always present, and redundant), so I'm thinking to enforce the suspension state at the level of the main process:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p><a href="http://community.jboss.org/servlet/JiveServlet/showImage/2-563527-9328/process.jpg"><span> http://community.jboss.org/servlet/JiveServlet/downloadImage/2-563527-9328/450-254/process.jpg </span></a></p><div> </div><div> </div><div><div>I cannot use the execution suspension of the main process, because of the timer's requisite (execution "<strong>suspended</strong>" state, also suspend timers and notifications),and I cannot <em>end</em> the sub-process because formally, at the end of the "wait" period it must progress where the sub-process was left.</div><div> </div><div>The problem is that when signaling the main execution to the "Suspend" state, there is a running sub-process instance that invalidate the operation:</div></div><p style="min-height: 8pt; height: 8pt; padding: 0px;"> &#160;</p><ol><ol><ol><li level="3" type="ol"><p> EXCEPTION ###########################################10:42:32,067 INF | <a class="" href="http://community.jboss.org/message/563527#563527">Signal a wait state and suspend related running subprocesses</a> exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd@3ce40org.jbpm.api.JbpmException: execution[MainProcess.50026] has running subprocess: execution[SubProcessRequisitesEvaluation.340002] in state inactive-scope&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1090)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:427)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.DefaultCommandService.execute(DefaultCommandService.java:42)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.SpringCommandCallback.doInTransaction(SpringCommandCallback.java:45)&#160;&#160;&#160;&#160;&#160;at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:130)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.tx.SpringTransactionInterceptor.execute(SpringTransactionInterceptor.java:49)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.executeInNewEnvironment(EnvironmentInterceptor.java:53)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.EnvironmentInterceptor.execute(EnvironmentInterceptor.java:40)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.RetryInterceptor.execute(RetryInterceptor.java:56)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.svc.ExecutionServiceImpl.signalExecutionById(ExecutionServiceImpl.java:93)</p></li></ol></ol></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><div> </div><div> </div><div><div>I've tried to suspend the sub-process activity execution and resume the main-process activity that maps the sub-process execution (the one in "inactive-scope" state) but it have no effect: </div></div><div> </div><div><p>... ExecutionImpl execution = (ExecutionImpl) executionService.findExecutionById(processId);logger.info( "MAIN-PROCESS STATE= " + processId + " " + execution.getState() );if(execution.getSubProcessInstance() != null){&#160;&#160;&#160;&#160;&#160;logger.info( "SUB_PROCESS STATE= " + execution.getSubProcessInstance().getId() + " " + &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;execution.getSubProcessInstance().getState() );&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;if(Execution.STATE_INACTIVE_SCOPE.equalsIgnoreCase(execution.getSubProcessInstance().getState())){&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;ExecutionImpl state = execution.getSubProcessInstance().findActiveExecutionIn(activeState);&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;state.suspend();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;execution.getSubProcessInstance().suspend();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;logger.info( "SUB_PROCESS STATE= " + execution.getSubProcessInstance().getId() + " " + &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;execution.getSubProcessInstance().getState() );&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;logger.info( "SUB_PROCESS ACTIVITY STATE " + state + " " + state.getState() );&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;execution.resume();&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;logger.info( "MAIN-PROCESS STATE " + execution + " " + execution.getState() );&#160;&#160;&#160;&#160;&#160;}}&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;executionService.signalExecutionById(processId, transitionName, variables); </p></div><div> </div><div> </div><div>this is the log:</div><div> </div><div><p>INFO&#160; ProcessServiceBean - Active state: EVALUATIONINFO&#160; ProcessServiceBean - MAIN-PROCESS STATE= MainProcess.50026 active-rootINFO&#160; ProcessServiceBean - SUB_PROCESS STATE= SubProcessRequisitesEvaluation.340002 inactive-scopeINFO&#160; ProcessServiceBean - SUB_PROCESS STATE= SubProcessRequisitesEvaluation.340002 suspendedINFO&#160; ProcessServiceBean - SUB_PROCESS ACTIVITY STATE= execution[SubProcessRequisitesEvaluation.340002.TaxCompliance.340005] suspendedINFO&#160; ProcessServiceBean - MAIN-PROCESS STATE execution[MainProcess.50026] active-root### EXCEPTION ###########################################12:05:39,201 INF | <a class="" href="http://community.jboss.org/message/563527#563527">Signal a wait state and suspend related running subprocesses</a> exception while executing command org.jbpm.pvm.internal.cmd.SignalCmd@ebd0beorg.jbpm.api.JbpmException: execution[MainProcess.50026] has running subprocess: execution[SubProcessRequisitesEvaluation.340002] in state suspended&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.model.ExecutionImpl.checkActive(ExecutionImpl.java:1090)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.model.ExecutionImpl.signal(ExecutionImpl.java:427)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:61)&#160;&#160;&#160;&#160;&#160;at org.jbpm.pvm.internal.cmd.SignalCmd.execute(SignalCmd.java:35 </p></div><div> </div><div><div>So, I'm wondering if the behaviour of Jbpm is wrong or if it's supposed to work in this way (namely: "cannot signal parent execution id subprocess are suspended"),&#160; or BTW if there is a common way to implement this set of requisites.</div><div> </div><div> </div><div>thank you in advance for any help you can give me!</div></div><div> </div><div> </div><div> </div></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/563527#563527">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>