Handling subprocess events
by Ryan Dowell
Just started with JBPM in the last couple weeks and I have a question regarding how to handle subprocesses.
As I understand it, when a process defines a subprocess as part of its workflow, then when that subprocess is executed, a new ProcessInstance is created but there is no externally visible state on either the parent or child referring to the other. I understand that the parent process is able to map its variables to inputs/outputs on the subprocess but what I'd like to do is also get info on the current runtime state of the child from a class that manages the parent. Currently I'm creating ProcessInstances inside of a wrapper class and the intention was to make the wrapper class able to reference the subprocess ProcessInstances as well.
My question is in regards to the ProcessEventListener interface. It is possible to catch a 'BeforeNodeTriggered' event and examine the event context to determine the node type and see if it is a SubProcessNode as well as the Process ID to determine the type of subprocess that is about to start. However, this occurs before the subprocess begins execution so there is no way to get the ProcessInstance ID for the subprocess at this point. It is also possible to catch the 'BeforeProcessStarted' event and get both a Process ID and ProcessInstance ID, however as noted earlier, even if the ProcessInstance for this particular event is a child of another ProcessInstance, there is nothing in the context of the event at this point that would associate it to its parent. The question is: because the execution engine is said to be single-threaded, can I safely make the assumption that if I catch a 'BeforeNodeTriggered' event, where the node type is a SubProcessNode with a given Process ID, then if I subsequently catch a 'BeforeProcessStarted' event with the same Process ID, that new ProcessInstance will always represent the child subprocess that was triggered by the parent, and it cannot be a separate instance started independently from a different source?
Thanks,
-Ryan D.
________________________________
PLEASE NOTE: The information contained in this electronic mail message is intended only for the use of the designated recipient(s) named above. If the reader of this message is not the intended recipient, you are hereby notified that you have received this message in error and that any review, dissemination, distribution, or copying of this message is strictly prohibited. If you have received this communication in error, please notify the sender by telephone or e-mail (as shown above) immediately and destroy any and all copies of this message in your possession (whether hard copies or electronically stored copies).
10 years, 3 months