AnsweredAssumed Answered

Exceptions while trying to resume tasks after lengthy jobs

Question asked by raadhakrishnaa on May 30, 2012
Latest reply on Jun 13, 2012 by frederikheremans1
As a beginner to Activiti,I am struggling to get my Usecase addressed.Details as follows
A.Scenario :
My ProcessDefinition constitutes multiple activities(predominantly service tasks),of which many of the activities require heavy IO and hence time-taking.
For a servicetask that corresponds to one such I/O activity,I want the ActivitEngine state to be persisted and resume the next sequence of workflow ,based on a signal received from the external business task

B.My Current Approach
All the descriptions laid here are in reference to the enclosed piece of code below.I have my workFlowDefinition as seen in "MyWorkFlowDefinition.bpmn20.xml" section .The service tasks correspond to execution of methods contained in Java bean "myBean".
I have my current setup working through Spring Integration.So the object "myBean" can carry references to RunTimeService,taskService etc of Activiti. The myBean object then invokes the external business Logic ,passing the reference of executionId,ProcessInstanceId of current executionContext . The external business code,at the end of execution wants to signal the WorkFlowEngine ,that it can resume the workflow with next sequence of tasks of workFlowDefinition.

<?xml version="1.0" encoding="UTF-8"?>
<definitions id="definitions"
  <process id="SequenceExecution">
    <startEvent id="start" />
    <sequenceFlow id="flow1-step1" sourceRef="start" targetRef="step1" />
    <serviceTask id="step1" activiti:expression="#{myBean.method1(arg1,arg2,arg3,arg4,execution)} " />
     <receiveTask id="flow2-step2" name="flow2-step2" />         
    <sequenceFlow id="flow3-step2" sourceRef="flow2-step2" targetRef="step2"/>
    <serviceTask id="step2" activiti:expression="#{myBean.clearThePain(execution)} " />
      <sequenceFlow id="flow4-step3" sourceRef="step2" targetRef="end" />
    <endEvent id="end" />


=============================================Spring Integrated Logic==========================================================================

public class myBean {
//Spring initialized service components like
TaskService taskService;
ManagementService mngService;
RunTimeService runtimeService;

public void method1(String arg1,String arg2,String arg3,String arg4,ActivityExecution execution){

print("Entered method.Proceed for execution …");
//…..invoke external code
String executionId=execution.getId();
String engineProcessId=execution.getProcessInstanceId();
new extBean().executeLogic(this,executionId,engineProcessId);


public void clearThePain(){

print("Got the control back to WorkFlowEngine.Executing Final task…");


=============================================External Logic==========================================================================

public class Extbean{

public Extbean(){}

public void executeLogic(myBean beanObj,String executionId,String processEngineId){
  //// Execute the business logic.
  myBean myBeanObj=beanObj;


C.Challenges Seen

When I invoke the above code,I see an exception as below

May 30, 2012 12:23:47 PM org.activiti.engine.impl.interceptor.CommandContext close
SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: execution flow1-step1 doesn't exist
        at org.activiti.engine.impl.cmd.SignalCmd.execute(
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(
        at org.activiti.engine.impl.interceptor.CommandContextInterceptor.execute(
        at org.activiti.spring.SpringTransactionInterceptor$1.doInTransaction(
        at org.activiti.spring.SpringTransactionInterceptor.execute(
        at org.activiti.engine.impl.interceptor.LogInterceptor.execute(
        at org.activiti.engine.impl.RuntimeServiceImpl.signal(

I also tried to pass the id of the receivetask "flow2-step2" and the exception thrown says

SEVERE: Error while closing command context
org.activiti.engine.ActivitiException: execution flow2-step2 doesn't exist
        at org.activiti.engine.impl.cmd.SignalCmd.execute(
        at org.activiti.engine.impl.interceptor.CommandExecutorImpl.execute(
D.Help Needed on
What am I doing wrong here?What is the ideal way of passing reference of current execution context to the external logic such that the WorkFlowEngine can be signalled and activated from its wait state for further execution.
Is this an ideal usecase that can fulfilled with ExecutionListeners or AsyncContinuation aspects of the documentation.If so,Please provide a sample direction of how it can be done

Can someone please help me or offer me hints to do this correctly.

Thank you,