<!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;">
    How to Send Signal Out from a WorkItemHandler?
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/brucecui">Bruce Cui</a> in <i>jBPM</i> - <a href="http://community.jboss.org/message/612163#612163">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>I have been trying to implement multi-threading processes with jBPM, as well as time consuming batch tasks. I found the console was executing the processes in one same main thread, at least so appeared to me, so I tried to put the task logic in a Thread instance and started it in the WorkItemHandler. For single thread but time consuming tasks, which I need to wait for the return, I also passed the ProcessInstance as a parameter, so that when the thread finished its job, it could send out a signal togher with a return Object to notify the process to move forward. And while it was running, it would't occupy the main thread for long time.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Local testing seems fine, only the job wouldn't exit after all things done. Then I put all stuf on web, but this time I met several exceptions, saying like: "java.lang.IllegalArgumentException: IOException while storing workItem 1: org.jbpm.workflow.instance.impl.WorkflowProcessInstanceImpl$1"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>and "Could not commit session or rollback"</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So I guess I should not pass the instance reference out, otherwise session may not be able to close or something. But is there a way to signal out from the WorkItemHandler or the Thread it starts, so that I can notify the process instance?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I see there are external signals, but it requires reference to ksession. But I didn't find a clue from either the docs or the API about acquire the ksession reference properly. Could you be so kind to help me out here? Or else I'll have to give up, since time consuming tasks running in the same main thread together will surely be a nightmare.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Bruce</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/612163#612163">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>