<!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;">
[jBPM4.4] process instance is in STATE_ASYNC
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/jeeyi">Jee Yi</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/640693#640693">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,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>I have defined a workflow so that it starts asynchronously.  And there is a custom activity that implements ExternalActivity.  In the execute method, I create Runnable object and submit to a custom thread pool, and then call execution.waitForSignal().  The new thread runs its own tasks and signals the execution in "work".</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>In the new thread, where it looks for the active execution in "work" sometimes throws an exception:</p><p><span class="pygments-n">Execution</span><span class="pygments-"> </span><span class="pygments-n">execution</span><span class="pygments-"> </span><span class="pygments-o" style="color: #666666;">=</span><span class="pygments-"> </span><span class="pygments-n">processInstance</span><span class="pygments-o" style="color: #666666;">.</span><span class="pygments-na" style="color: #7d9029;">findActiveExecutionIn</span><span class="pygments-o" style="color: #666666;">(</span><span class="pygments-s" style="color: #ba2121;">"work"</span><span class="pygments-o" style="color: #666666;">);</span></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The reason is because the state of the process instance is STATE_ASYNC and not STATE_ACTIVE_ROOT.  Does anyone know why?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This is web application and we start multiple process instances concurrently.  We are using jBPM JobExecutor with default configuration.  When I start about 10 process instances, I see one or two process instances failed to move on to the next activity because we were not able to signal the execution. </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>1) Does anyone know what's going wrong here?</p><p>2) Any suggestion how to make process instance move from STATE_ASYNC to STATE_ACTIVE_ROOT?</p><p>3) Or is there a way to signal process instance in STATE_ASYNC?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><table cellpadding="0" cellspacing="0" style="color: #000000; font-family: sans-serif; font-size: medium; border-style: none;"><tbody><tr class="vc_row_odd" id="l5" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="5">5</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">    </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"><start</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">name=</span><span class="pygments-s" style="color: #ba2121;">"async-start"</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">continue=</span><span class="pygments-s" style="color: #ba2121;">"async"</span><span class="pygments-"> </span><span class="pygments-nt" style="color: #008000; font-weight: bold;">></span><span class="pygments-"></span> </td></tr><tr class="vc_row_odd" id="l6" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="6">6</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">        </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"><transition</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">to=</span><span class="pygments-s" style="color: #ba2121;">"work"</span><span class="pygments-nt" style="color: #008000; font-weight: bold;">/></span><span class="pygments-"></span> </td></tr><tr class="vc_row_odd" id="l7" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="7">7</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">    </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"></start></span><span class="pygments-"></span> </td></tr><tr class="vc_row_odd" id="l8" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="8">8</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">    </span> </td></tr><tr class="vc_row_odd" id="l9" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="9">9</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">    </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"><custom</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">name=</span><span class="pygments-s" style="color: #ba2121;">"work"</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">expr=</span><span class="pygments-s" style="color: #ba2121;">"#{startWorkAndWait}"</span><span class="pygments-"> </span><span class="pygments-nt" style="color: #008000; font-weight: bold;">></span><span class="pygments-">             </span> </td></tr><tr class="vc_row_odd" id="l10" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="10">10</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">        </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"><transition</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">name=</span><span class="pygments-s" style="color: #ba2121;">"ok"</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">to=</span><span class="pygments-s" style="color: #ba2121;">"send mail"</span><span class="pygments-"> </span><span class="pygments-nt" style="color: #008000; font-weight: bold;">/></span><span class="pygments-">  </span> </td></tr><tr class="vc_row_odd" id="l11" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="11">11</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-">        </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"><transition</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">name=</span><span class="pygments-s" style="color: #ba2121;">"error"</span><span class="pygments-"> </span><span class="pygments-na" style="color: #7d9029;">to=</span><span class="pygments-s" style="color: #ba2121;">"send error mail"</span><span class="pygments-"> </span><span class="pygments-nt" style="color: #008000; font-weight: bold;">/></span><span class="pygments-">  </span> </td></tr><tr class="vc_row_odd" id="l12" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="12">12</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><span class="pygments-"><p><span class="pygments-">    </span><span class="pygments-nt" style="color: #008000; font-weight: bold;"></custom></span><span class="pygments-"> </span> </p></span></td></tr><tr class="vc_row_odd" id="l13" style="background-color: #f0f0f0;"><td class="vc_file_line_number" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: right;color: #505050;background-color: #eeeeee;border-right-width: 1px;"><a class="jive-link-anchor-small" name="13">1</a></td><td class="vc_file_line_text" style="border-style: none;padding-left: 5px;padding-bottom: 1px;padding-right: 5px;padding-top: 1px;font-style: normal;font-weight: normal;border-right-color: #505050;border-right-style: solid;text-align: left;font-family: monospace;background-color: white;"><br/></td></tr></tbody></table><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><a class="jive-link-anchor-small">public <span class="bold"><strong>class StartWorkAndWait</strong></span> implements <span class="bold"><strong>ExternalActivity</strong></span> {<br/><br/>  public void execute(ActivityExecution execution) {</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>    // created Runnable and submitted to a custom ThreadPool</p><p><a class="jive-link-anchor-small"><br/>    <span class="bold"><strong>execution.waitForSignal();</strong></span><br/>  }<br/><br/>  public void signal(ActivityExecution execution, <br/>                     String signalName, <br/>                     Map<String, Object> parameters) {<br/>    <span class="bold"><strong>execution.take(signalName);</strong></span><br/>  }<br/>}</a></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Thanks,</p><p>Jee</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/640693#640693">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>