-
1. Re: How to recognize when async-node is finished?
sebastian.s Jun 16, 2010 1:48 AM (in response to johannesk)1 of 1 people found this helpfulMaybe you want to use an EventListener on the transition?
-
2. Re: How to recognize when async-node is finished?
johannesk Jun 16, 2010 5:40 AM (in response to sebastian.s)Sorry, I forgot to add that I'm using Jbpm 3.2.6 SP1. I can't see any EventListener in the API, is it maybe new to Jbpm4? Is there any possibility to use something like that with Jbpm3.
Another thing I've tried is adding the monitor.notifyAll() as a separate Event to the outgoing transition. It still only works, if I wait some time after the notification to send the second signal.
Has nobody ever tried to continue a process immediately after an async node has finished its execution? How should it work?
-
3. Re: How to recognize when async-node is finished?
mohreece Jun 17, 2010 4:40 AM (in response to johannesk)Johannes,
This is a problem we've been facing as well, e.g. in testing: how long do you wait for an async execution to end? There's no mechanism in jBPM 3 (as far as I know) to be notified that such an execution has ended, and determining the end of the execution is somewhat non-deterministic - it would take into account the time used for scheduling the async command(s) and executing the corresponding code.
One mechanism available in Hibernate is to register a hook (an implementation of Synchronization) to the async transaction (something I tried to explain here: http://community.jboss.org/message/399790#399790), but that only works if you are able to set up that hook.
An approach we've been using as well is to simply poll for the async execution to be ended (using relative short cycles with sleeps in between). I would agree if you'd say that's just butt-ugly, but we've found it works for us - lacking a better solution.
Regards,
Maurice
-
4. Re: How to recognize when async-node is finished?
johannesk Jun 22, 2010 5:34 AM (in response to mohreece)The solution with a Synchronization object works like a charme. The async node now takes the JbpmContext from the ExecutionContext, then the Session and finally the hibernate Transaction to register a new Synchronization which performs a monitor.notifyAll() in afterCompletion(int).
I've attached the modified version of the original test project in case someone wants to have a look at it.
Thanks a lot for your answer!
-
asyncTest.zip 5.3 KB
-