<!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="https://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;">
    persistent state of process and resume of process
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="https://community.jboss.org/people/rudi_fisher">Rudi Fisher</a> in <i>jBPM</i> - <a href="https://community.jboss.org/message/729791#729791">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 a situation where I need to resume process execution after restart of jBPM (restart of JBoss). I'm working with work item handlers and I want to have possibility to resume of execution of asynchronous work item handlers. Everything is working fine for my implementation if jBPM is running but problem is if I restarted jBPM (JBoss).</p><p>Situation is:</p><p>I implemented "go to shutdown" functionality which works in this way: if "go to shutdown" global attribute of system is set, then at the begining of method executeWorkItem return is called and work item is not executed at all. This means no work item is executed if this attribute is set in my system. Also no new process can't be created or started. After while all process are in wait state and state of processes is persisted.</p><p>After this JBoss is restarted.</p><p>Then I'll turn off "go to shut down" atttribute and call my resumeProcesses functionality. This functionality will takes all not finished work items from WorkItemInfo table and call executeWorkItem for every work item. This will cause that body of work item'll be executed and if success method completeWorkItem will be executed. This works if JBoss is not restarted but if JBoss is restarted, workitem is completed but process doesn't continue with execution of next node.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>I'm confused because this is working if Jboss is not restarted so this means that process is not persisted "correcly". I found where is the problem. After JBoss is restarted every processInstace which is going to use have to be read from persisted state - see AbstractProcessInstanceMarshaller.readProcessInstance. In this method reconect method is called where correct listeners are added for all node instances, but I'm confused that there is a previous node used, not node of my last work item. This will cause that there are added only listeners for my previous work item which was already succesfully completed. This is difference if Jboss is not restarted because process instance is not loaded from persistent state and is used from session and there is corrrect node.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Is this how process persistence should work or is this some bug or I'm missing something about this. Thank you for any advice.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Another plan is to modify process somehow in runtime and add event to wait for signal to achieve this resume functionlity but i think this is not a good idea.</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="https://community.jboss.org/message/729791#729791">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in jBPM at <a href="https://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>