AnsweredAssumed Answered

Overcome StackOverFlow without extenal trigger

Question asked by gul on Jun 19, 2015
Latest reply on Jun 21, 2015 by trademak
I am trying to convert 11 complex workflows from JBPM to Activiti.  They all contain serviceTasks only; and they all have one more multi-task loops. As shown in attached image.  Cardinality of such loops could reach 60. So; I am facing StackOverFlow Errors.
I introduced a RecieveTask. My aim with RecieveTask; is to save ”callStack” into DB and continue the loops, until it exits based on exclusive-gate condition.

Option 1: Add executionListener;

<receiveTask id="waitTask" name="Dummy Wait State to force db commit">
        <extensionElements>
               <activiti:executionListener event="start" delegateExpression="${receiveTaskListener}"/>
            </extensionElements> 
    </receiveTask>


@Component("receiveTaskListener")
public class ReceiveTaskListener implements ExecutionListener {   
   public void notify(DelegateExecution execution) throws Exception {      
      Task task = execution.getEngineServices().getTaskService().createTaskQuery()
            .taskDefinitionKey("waitTask").singleResult();
      execution.getEngineServices().getTaskService().complete(task.getId());
   }

}

This setup throws “already taking a transition” exeception.

Option 2: Add EventListener.

public class ProcessListener implements ActivitiEventListener {   
   @Override
   public void onEvent(ActivitiEvent event) {
      switch (event.getType()) {
      case ACTIVITY_STARTED:
         ExecutionQuery q = event.getEngineServices().getRuntimeService().createExecutionQuery();
         List<Execution> executions = q.processInstanceId(event.getProcessInstanceId())
               .activityId("waitTask").list();
         if (executions != null) {            
            for (Execution execution : executions) {
               event.getEngineServices().getRuntimeService().signal(execution.getId());
            }
         }


This signal stops the entire execution.  Can someone please suggest, on how to continue the loops without StackOverFlow error.  Note: I cannot have external triggers(like JMS or Thread waits).

Attachments

Outcomes