JBPM5 - Multiple Instances Component
Posted by bpmn2user in bpmn2 user's Blog on Mar 5, 2011 11:00:48 PMJBPM5 provides 'Multiple Instances' node that can be used to create multiple instances of reusable sub-processes.
Here is a simple example that shows how to send a colection of elements to sub-process nodes and invoke mutiple processes.
The example from the discussion http://community.jboss.org/thread/163105?tstart=0 is considered here to illustrate the usage.
It has a main process (sampleMultiLoopSubprocessTest.bpmn) that invokes multiple sub-processes (multilooptest777.bpmn).
The main process sends a list of parameters (initial count ) to the sub-process.
The sub-process goes through a loop incrementing the value of 'count'. Once the 'count' reaches the 'do until' loop condition value, it will exit the loop.
A list to contain the parameters that need to be sent to sub-processes are populated as shown below (MultiLoopProcessTest.java).
Map<String, Object> params = new HashMap<String, Object>();
List<Integer> myList = new ArrayList<Integer>();
myList.add(process1Count);
myList.add(process2Count);
params.put("list", myList);
ksession.startProcess("com.sample.bpmn.multilooptest",params);
The 'CollectionExpression' is set to 'list' as shown below,
The ProcessID is set to 'multilooptest777' as shown below to bind the sub-process.
How to run this example?
This example has two bpmn files (sampleMultiLoopSubprocessTest.bpmn for main process that invokes multiple processes and multilooptest777.bpmn for sub-process loop) and a test file (LoopSubProcessTest.java). It might be easy to start with a HelloProcess project (http://community.jboss.org/people/bpmn2user/blog/2011/02/27/helloprocess-example-using-jbpm5-eclipse-plug-in) and import these files.
Following results can be seen after successfully running this example.
-
multilooptest777.bpmn.zip 1.4 KB
-
MultiLoopProcessTest.java.zip 891 bytes
Comments