Community

Fork activities with assignment handlers

created by Janarthanan K S in jBPM Development - View the full discussion

Hi

 

The fork activities does not end in join while using assignment-handlers in the tasks. Following is my jpdl. It seems the control does not goes beyond the task "Parallel Queue".

 

Is the way I handle the fork is correct?

 

-------------------------------------------------------------------------------

hello_world.assignee.jpdl.xml

-------------------------------------------------------------------------------

<?xml version="1.0" encoding="UTF-8"?>
<process name="helloWorld" xmlns="http://jbpm.org/4.3/jpdl">
<start g="27,248,80,40">
<transition to="fork1"/>
</start>
   <fork g="158,247,91,65" name="fork1">
      <on continue="exclusive" event="printHelloEnd"/>
      <transition g="182,486:" to="Parallel Queue"/>
      <transition g="182,61:121,-15" name="world" to="printHelloWorld"/>
   </fork>
   <join g="513,267,61,49" name="join1" continue="exclusive">
      <transition to="printHelloEnd"/>
   </join>
   <task g="224,457,211,57" name="Parallel Queue">
   <assignment-handler class="cos.workflow.helloworld.HelloWorldAssignmentHandler"/>
      <transition g="537,487:" to="join1"/>
   </task>
<java class="cos.workflow.helloworld.Printer" g="468,42,138,40" method="printHelloWorld" name="printHelloWorld">
      <transition g="13,-27" name="join" to="join1"/>
</java>
   <java class="cos.workflow.helloworld.Printer" g="664,268,116,48" method="printHelloEnd" name="printHelloEnd">
<transition to="theEnd"/>
   </java>
<end g="893,269,80,40" name="theEnd"/>
</process>

 

-------------------------------------------------------------------------------

cos.workflow.helloworld.Main

-------------------------------------------------------------------------------

 

public class Main {

public static void main(String[] args) {

 

// Build jBPM services

ProcessEngine processEngine = new Configuration().setResource("workflow.jbpm.cfg.xml").buildProcessEngine();

RepositoryService repositoryService = processEngine.getRepositoryService();

ExecutionService executionService = processEngine.getExecutionService();

 

// Deploy helloWorld process definition and start a process instance

repositoryService.createDeployment().addResourceFromClasspath("hello_world.assignee.jpdl.xml").deploy();

ProcessInstance processInstance = executionService.startProcessInstanceByKey("helloWorld");

TaskService taskService = processEngine.getTaskService();

String pid = processInstance.getId();

 

List < Task > taskList = taskService.findPersonalTasks("admin");

        Task task = taskList.get(0);

        taskService.completeTask(task.getId());

        processInstance = executionService.findProcessInstanceById(pid);

 

}

}

 

 

-------------------------------------------------------------------------------

cos.workflow.helloworld.HelloWorldAssignmentHandler

-------------------------------------------------------------------------------

public class HelloWorldAssignmentHandler implements COSAssignmentHandler {

 

/**

*

*/

private static final long serialVersionUID = 1L;

String userId;

 

/* (non-Javadoc)

* @see org.jbpm.api.task.AssignmentHandler#assign(org.jbpm.api.task.Assignable, org.jbpm.api.model.OpenExecution)

*/

public void assign(Assignable assignable, OpenExecution execution)

throws Exception {

userId = "admin";

System.out.println("cos.workflow.helloworld.HelloWorldAssignmentHandler");

assignable.setAssignee(userId);

 

}

 

}

-------------------------------------------------------------------------------

cos.workflow.helloworld.Printer

-------------------------------------------------------------------------------

public class Printer {

public void printHelloWorld() {

System.out.println("<---------------->");

System.out.println("   HELLO WORLD!");

System.out.println("<---------------->");

}

public void printHelloEnd() {

System.out.println("<---------------->");

System.out.println("   HELLO END!");

System.out.println("<---------------->");

}

}

 

 

Thanks

Jana.

 

Reply to this message by going to Community

Start a new discussion in jBPM Development at Community