-
1. Re: Jbpm saveProcessInstance design
ejimenez Dec 8, 2005 3:48 PM (in response to ejimenez)Well, came up with another workaround, used the subprocess-created and subprocess-end events in the process-state node to save the process instance....
-
2. Re: Jbpm saveProcessInstance design
tom.baeyens Dec 9, 2005 5:34 AM (in response to ejimenez)you might have a very specific situation where subprocessing fails.
in case you have multiple subprocesses that don't have wait states. because the token has only 1 pointer to the current subprocess.
we might fix this later but this has no priority atm. although we also want to support processes without wait states, they are not our main target and it is considered a rare situation.
regards, tom. -
3. Re: Jbpm saveProcessInstance design
tom.baeyens Dec 9, 2005 5:36 AM (in response to ejimenez)the real solution will be to keep a list of all the subprocesses in the ProcessInstance (in a member that is not persisted with hibernate)
then the save operation can take this list and store the subprocesses properly. this technique is similar as with e.g. logs, timers, ...
regards, tom. -
4. Re: Jbpm saveProcessInstance design
ejimenez Dec 9, 2005 10:13 AM (in response to ejimenez)Yes, agreed, that might be the best solution. But, here's another problem. The subprocess-end event is useless if the context's token does not have the subProcessInstance field set.
See, token.subprocessinstance is not a persistent field, which means that if the subprocess is started, then loaded in a different hibernate session later, the token.subprocessinstance field is null, which means that if you have an action on a subprocess-end event, its not going to know which subprocess ended.
making the list of subprocesses is great, but it doesn't solve this problem. My gut feeling is that this should be treated as it is treated during subprocess creation:public void execute(ExecutionContext executionContext) { Token superProcessToken = executionContext.getToken(); // create the subprocess ProcessInstance subProcessInstance = new ProcessInstance(subProcessDefinition); // bind the subprocess to the super-process-token superProcessToken.setSubProcessInstance(subProcessInstance); subProcessInstance.setSuperProcessToken(superProcessToken); // fire the subprocess created event fireEvent(Event.EVENTTYPE_SUBPROCESS_CREATED, executionContext); .....
See how the superProcessToken gets a nice setSubProcessInstance? That way the subprocess-created event knows which subprocess was created.
The current code on notifySubProcessEnd is:public void notifySubProcessEnd(ProcessInstance subProcessInstance) { Token superProcessToken = subProcessInstance.getSuperProcessToken(); ExecutionContext executionContext = new ExecutionContext(superProcessToken); // feed the readable variables if ((variableAccesses != null) && (!variableAccesses.isEmpty())) { .... .... } // feed the readable variables fireEvent(Event.EVENTTYPE_SUBPROCESS_END, executionContext); ....
I think it is very reasonable to do insteadpublic void notifySubProcessEnd(ProcessInstance subProcessInstance) { Token superProcessToken = subProcessInstance.getSuperProcessToken(); superProcessToken.setSubProcessInstance(subProcessInstance); ExecutionContext executionContext = new ExecutionContext(superProcessToken); // feed the readable variables if ((variableAccesses != null) && (!variableAccesses.isEmpty())) { .... .... } // fire the subprocess ended event fireEvent(Event.EVENTTYPE_SUBPROCESS_END, executionContext); ....
In this way, the subprocess-end event will pass a context where the token correctly contains the subprocess instance even if being loaded after being persisted while the subprocess was going on.
I will post a JIRA bug with this same info. -
5. Re: Jbpm saveProcessInstance design
ejimenez Dec 9, 2005 10:20 AM (in response to ejimenez)tom, processes with no wait states are rare. Our process do have wait states wrapped in decision nodes. Because all the decisions are negative, the subprocess doesn't have anything to do so it ends.
One more thing, how could you have multiple subprocess per token?
If you want to start multiple processes you'd have to Split, which means you would have multiple tokens and each would have a different superprocessinstance, right? -
6. Re: Jbpm saveProcessInstance design
ejimenez Dec 9, 2005 10:38 AM (in response to ejimenez)Bug is in JIRA: JBPM-462
-
7. Re: Jbpm saveProcessInstance design
kukeltje Dec 9, 2005 11:09 AM (in response to ejimenez)right, one subprocess per token
-
8. Re: Jbpm saveProcessInstance design
ejimenez Dec 9, 2005 11:43 AM (in response to ejimenez)by split I meant fork :-p
-
9. Re: Jbpm saveProcessInstance design
kukeltje Dec 9, 2005 1:30 PM (in response to ejimenez)isn't a fork a splitted spoon?