[rules-users] completing persisted workItem (the last in a process) doesn't complete a process

Kris Verlaenen kris.verlaenen at cs.kuleuven.be
Tue Apr 12 12:14:11 EDT 2011


A process instance is "disconnected" once the command is completed.  
This means that it will represent the state at the end of the command 
and won't be updated when the process instance actually changes.  You 
can however always get the latest snapshot using 
ksession.getProcessInstance(id).  There are a few reasons for doing this:
 * It allows a process instance to be updated from two separate 
sessions, since the process instance will be reloaded from database when 
it is needed again, so it will take the changes into account that were 
introduced by another session.
 * When using persistence, you're not supposed to manipulate the process 
instance directly (as this will be out of the scope of the transaction 
and the engine wouldn't be aware), disconnecting the instance means you 
can't, you're supposed to treat it as a data object.
 * This also allows remoting where the process instance can be sent to 
anywhere else (and here the use of a DTO that represents a snapshot it 
common)

Note that this is only when you are using persistence, when using the 
core engine directly, you get access to the "live" process instance 
directly.

Kris

Dan Nathanson wrote:
> I ran into this issue also.  I was told that the ProcessInstance you
> are looking at is just a snapshot of what was loaded from the DB.  It
> doesn't get updated after being loaded.  I wasn't told why this was
> the behavior, just that it was expected.  Didn't seem intuitive to me.
>  I was told that the way to check for process completion is to try to
> load the process from the DB again and if it is null, then it is
> complete.  I didn't like that solution so I wrote a
> ProcessEventListener to detect process completion because I needed to
> send a JMS message.
>
> Regards,
>
> Dan Nathanson
>
>
>
> On Tue, Apr 12, 2011 at 7:18 AM, gs76pl <gstasica at pacemetrics.com> wrote:
>   
>> for those interested the problem was that i misinterpreted ProcessInstance
>> object as something that always gets updated whenever underlying process
>> changes, whereas in fact that's the version of a process obtained at the
>> specific moment. This is especially true while working with persistence. So
>> the bottom line is that in order to check process status the best way to do
>> it is to create ProcessEventListener object and add it to the created
>> session....
>>
>> similar thread http://comments.gmane.org/gmane.comp.java.drools.user/24622
>>
>> --
>> View this message in context: http://drools.46999.n3.nabble.com/completing-persisted-workItem-the-last-in-a-process-doesn-t-complete-a-process-tp2810593p2811574.html
>> Sent from the Drools: User forum mailing list archive at Nabble.com.
>> _______________________________________________
>> rules-users mailing list
>> rules-users at lists.jboss.org
>> https://lists.jboss.org/mailman/listinfo/rules-users
>>
>>     
> _______________________________________________
> rules-users mailing list
> rules-users at lists.jboss.org
> https://lists.jboss.org/mailman/listinfo/rules-users
>   




More information about the rules-users mailing list