-
1. Re: subprocess ? or task-node with *blocking* ?
aguizar Feb 3, 2006 12:16 AM (in response to forjbpm)Can I answer even if I'm not the "architect" of jBPM? :-) Alright, why don't you use a state? Upon node-enter, launch the external program, and when it completes, signal the waiting token. If you can't touch the external program to insert the signal at the end, you can wrap it using the java.lang.Process API. In particular, look for the waitFor() method.
Your question about subprocesses is answered in section 7.7, "process composition" of the jBPM user guide:The path of execution of the super process will wait till the sub process instance has ended
-
2. Re: subprocess ? or task-node with *blocking* ?
forjbpm Feb 3, 2006 4:05 PM (in response to forjbpm)oh! Thanks a lot for your quick answer. But problem here is, external program is perl program. I will go through all your suggestions.
As I didnt get any answer earlier, I started with a different approach. If I am not mistaken signalling token is nothing but changing node_ in *jbpm_token* field to leaving transition node ??? ( here I can get leaving transition from jbpm_task table (if tasknode_ is null Leaving Transition would be startstate_) .
If from my perl program I change jbpm_token for appropriate for appropriate node_ will that be enough? What else I would have to do in that case?? :-)
will get back soon! :-) -
3. Re: subprocess ? or task-node with *blocking* ?
aguizar Feb 3, 2006 5:01 PM (in response to forjbpm)Changing the database directly is not at all advisable, because jBPM will *not* realize you changed the node or "automagically" resume execution from there.
My suggestion was more along these lines. If your external program is sufficiently short lived, you can wait synchronously for it to finish. In this case you won't release the resources you have allocated (jBPM objects, JDBC connection). Use a node instead of a state and use this as the node action:public void execute(ExecutionContext exeContext) throws Exception { // execute external program Process p = Runtime.exec("yourprogram"); // wait for the program to terminate p.waitFor(); // resume the process exeContext.leaveNode(); }
If your program takes a long time to finish, you can use a separate thread in a non-managed environment or a message-driven bean in a managed environment. In this case all you need to keep is the token id, so that you can reload the token and send a signal. -
4. Re: subprocess ? or task-node with *blocking* ?
forjbpm Feb 6, 2006 12:53 PM (in response to forjbpm)Hi!
Thanks a lot!
I was under prejudice that process.waitFor() or process.wait() dosen't work correct on linux.
So I initially did not think about it. Whatever you said makes perfect sense. I was under impression that hibernation will take care of if i change something in database. huh!