AnsweredAssumed Answered

How do Timer intermediate catching event work?

Question asked by strae on Apr 21, 2011
Latest reply on Dec 23, 2015 by vasile.dirla
There are process:
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:activiti="http://activiti.org/bpmn" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:omgdc="http://www.omg.org/spec/DD/20100524/DC" xmlns:omgdi="http://www.omg.org/spec/DD/20100524/DI" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/test">
  <process id="Timer1" name="Timer1">
    <startEvent id="startevent1" name="Start">       
    </startEvent>  
    <endEvent id="endevent1" name="End"></endEvent>
    <serviceTask id="servicetask1" name="Service Task" activiti:class="org.activity.timer.Service2"></serviceTask>     
      <intermediateCatchEvent id="timer1" name="Timer1">
          <timerEventDefinition id="tmrcfg1">
              <timeDuration>PT100S</timeDuration>
         </timerEventDefinition>
      </intermediateCatchEvent> 
      <sequenceFlow id="flow1003" name="" sourceRef="timer1" targetRef="servicetask1"></sequenceFlow>
      <sequenceFlow id="flow1001" name="" sourceRef="startevent1" targetRef="timer1"></sequenceFlow>
      <sequenceFlow id="flow1002" name="" sourceRef="servicetask1" targetRef="endevent1"></sequenceFlow>
  </process>
</definitions>

I run it by java code:
public static void main(String[] args) {
Deployment deployment = ProcessEngines.getDefaultProcessEngine().getRepositoryservice()
            .createDeployment().addClasspathResource("Timer1").deploy();
ProcessEngines.getDefaultProcessEngine().getRuntimeservice().startProcessInstanceByKey("Timer1").getId();
}

I except that java thread start process and runtime is: from start event go to intermediateCatchEvent,  on the intermediateCatchEvent process wait 100 sec(as in configuration), then process go to serviceTask, from service task to end. But thread run without timeout 100 sec and serviceTask run immediately. What is the problem?
ServiceTask implementation:
public class Service2 implements JavaDelegate {
   public void execute(DelegateExecution execution) throws Exception {
      System.out.println("Process 2  done");
   }
}

Outcomes