1 of 1 people found this helpful
Maybe you want to use an EventListener on the transition?
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?
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.
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