JBoss Community

How to start/spawn 'n' subprocesses for 'n' users using JBPM-4.3.

reply from Al Nadein in jBPM - View the full discussion

swiderski.maciejMaciej,

 

Thanks for a prompt reply. I was able to achieve what i wanted.

 

Here's my sample process:

{code:xml}

<?xml version="1.0" encoding="UTF-8"?>

 

<process key="main" name="main" xmlns="http://jbpm.org/4.4/jpdl">
  
   <start g="-7,25,48,48" name="start">
      <transition g="-28,-16" name="to-open-case" to="Open Case"/>
   </start>
  
   <foreach g="254,18,48,48" in="#{events}" name="foreach" var="event">
      <transition to="Create a sub-process"/>
   </foreach>
  
   <custom g="96,16,126,52" name="Open Process">
      <transition g="-30,-34" name="to-create-subprocesses" to="foreach"/>
   </custom>


   <join g="490,18,48,48" multiplicity="#{quorum}" name="join">
      <transition g="-11,-14" name="to-end" to="end"/>
   </join>


   <end g="570,18,48,48" name="end"/>


   <sub-process g="334,16,124,52" name="Create a sub-process" sub-process-key="#{event}">
      <transition g="-12,-17" name="to-join" to="join"/>
   </sub-process>
    
</process>

{code}

 

Here's a client:

{code}
        Map<String, Object> variables = new HashMap<String, Object>();

 

        String[] events = new String[] { "sub1", "sub2", "sub3" };
        variables.put("events", events);
        variables.put("quorum", new Integer(events.length)); // join cardinality
       
        ProcessInstance processInstance = executionService.startProcessInstanceByKey("main", variables, "123");

{code}

 

The problem is - I don't seem to be able cascade delete after that - weather i start from main or any of its children, i'm falling into integrity constrains. The below fails:

{code}

List<ProcessDefinition> deployments = repositoryService
                .createProcessDefinitionQuery().processDefinitionKey("main").list();
        for (int i = 0; i < deployments.size(); i++) {
            ProcessDefinition pd = deployments.get(i);
            repositoryService.deleteDeploymentCascade(pd.getDeploymentId());
        }

{code}

Reply to this message by going to Community

Start a new discussion in jBPM at Community