AnsweredAssumed Answered

How to persist process state between 2 JavaDelegates?

Question asked by seb2013 on Jul 22, 2011
Latest reply on Jul 23, 2011 by trademak
Dear community,

I hava a simple setup with 2 JavaDelegates in sequence. If an exception is thrown in the 2nd class, the workflow stops as expected. If I start the excecution with the same business-key again, the 1st and 2nd task will be executed. So Activiti starts from beginning again. What I need is that Activity resumes at the 2nd step because the first step was already processed successfully previously. Somehow the context/state is not going to be persisted after the 1st step finished. Hope that somebody can help me with the right setup. I could not find anything about that in the forum. Below I attached the simplified java and deployment code.


  <process id="seq-exception" name="seq-exception">
    <startEvent id="startevent1" name="Start"></startEvent>
    <serviceTask id="servicetask2" name="Sucess" activiti:delegateExpression="#{MyJavaDelegate}"></serviceTask>
    <serviceTask id="servicetask1" name="Exception" activiti:delegateExpression="#{MyJavaDelegateWithException}"></serviceTask>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow1" name="" sourceRef="startevent1" targetRef="servicetask2"></sequenceFlow>
    <sequenceFlow id="flow2" name="" sourceRef="servicetask2" targetRef="servicetask1"></sequenceFlow>
    <sequenceFlow id="flow3" name="" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>

@Component(value = "MyJavaDelegate")
public class MyJavaDelegate implements JavaDelegate {

    private static final Logger logger = LoggerFactory.getLogger(MyJavaDelegate.class);

    public void execute(DelegateExecution execution) throws Exception {"MyJavaDelegate");


@Component(value = "MyJavaDelegateWithException")
public class MyJavaDelegateWithException implements JavaDelegate {

    private static final Logger logger = LoggerFactory.getLogger(MyJavaDelegateWithException.class);

    public void execute(DelegateExecution execution) throws Exception {"MyJavaDelegateWithException");
        throw new Exception("Dummy Exception");

public class MainBean {
    private RuntimeService runtimeService;

    public void execute(String processDefinitionKey, String businessKey) {
        ProcessInstance processInstance = runtimeService.startProcessInstanceByKey(processDefinitionKey,