cancel
Showing results for 
Search instead for 
Did you mean: 

Overcome StackOverFlow without extenal trigger

gul
Champ in-the-making
Champ in-the-making
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).
2 REPLIES 2

gul
Champ in-the-making
Champ in-the-making
Am I incorrect in trying to signal ReceiveTask within the workflow?.I fail to do so.  Or Should it only be done externally.

trademak
Star Contributor
Star Contributor
You could try to make the service task asynchronous. If the service task is multi instance (with 60 possible loops) then it's best to use an multi instance embedded sub process with an asynchronous service task. You could also try to raise the max stack size (like described here http://stackoverflow.com/questions/3700459/how-to-increase-the-java-stack-size).

Best regards,
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.