This content has been marked as final.
Show 1 reply
-
1. Re: Multiple Subprocess - jBPM 3.3.1
lucazammarchi Feb 4, 2010 5:53 AM (in response to lucazammarchi)Hi,
I implemented a solution that has the same result:
- I created some "process instances" from one process definition
- then I created an ExecuteNodeJob for each process instance and I sent it to the MessageService.
- In ArrayList I was putting all process instance ids
- With a timer I was checking all process and wait for all processes.
Below the function I use to create the process:
public long createSubProcess(ExecutionContext executionContext, String processName,HashMap variabili,boolean signalToken ){ //Create process instance ProcessInstance subProcessInstance = executionContext.getJbpmContext().newProcessInstance(processName); //Setting any variable Iterator iterator = variabili.keySet().iterator(); while(iterator.hasNext()){ String key=(String)iterator.next(); contextInstance.setVariable(key, variabili.get(key)); } Token token=subProcessInstance.getRootToken(); token.setNodeEnter(Clock.getCurrentTime()); //Signal the token of the process if needed if(signalToken) token.signal(); //Create the job ExecuteNodeJob job = new ExecuteNodeJob(token); job.setNode(token.getNode()); Calendar dataCorrente = Calendar.getInstance(); dataCorrente.add(Calendar.MINUTE, 1); job.setDueDate(dataCorrente.getTime()); job.setExclusive(true); //Send the job to the message service MessageService messageService = (MessageService)Services.getCurrentService("message"); messageService.send(job); token.lock(job.toString()); //Return the process instance id to the main program return subProcessInstance.getId(); }
I am testing this solution.
Has anyone a better idea?
I think this is a ploy help me to have multiple processes that running asynchronously.
Best regards.
Luca Zammarchi