cancel
Showing results for 
Search instead for 
Did you mean: 

Boundary timer event not trigered

patdab90
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to run a simple process with boundary time event . But after the expiration of the specified time nothing happens and event was not executed.



org.activiti.engine.ActivitiException: time limit of 6000 was exceeded
   at org.activiti.engine.impl.test.JobTestHelper.waitForJobExecutorToProcessAllJobs(JobTestHelper.java:86)
   at org.activiti.engine.impl.test.JobTestHelper.waitForJobExecutorToProcessAllJobs(JobTestHelper.java:47)
   at org.activiti.engine.impl.test.JobTestHelper.waitForJobExecutorToProcessAllJobs(JobTestHelper.java:40)
   at pl.nextbike.activiti.util.BoundaryTimerTest.boundaryTest(BoundaryTimerTest.java:42)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
   at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
   at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
   at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
   at org.activiti.engine.test.ActivitiRule$1.evaluate(ActivitiRule.java:126)
   at org.junit.rules.RunRules.evaluate(RunRules.java:20)
   at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
   at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
   at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
   at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
   at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
   at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
   at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
   at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
   at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
   at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
   at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
   at java.lang.reflect.Method.invoke(Method.java:497)
   at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
   at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
   at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
   at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
   at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)



   @Test
   @Deployment(resources = { "pl/nextbike/activiti/util/BoundaryTimerTest.boundaryTest.bpmn20.xml" })
   public void boundaryTest() throws InterruptedException {
      LOGGER.info("boundaryTest start.");
      Date startTime = new Date();
      ProcessInstance processInstance = activitiRule.getRuntimeService().startProcessInstanceByKey("PROCES_Z_TIMEREM");
      assertNotNull(processInstance);

      Task task = activitiRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
      assertNotNull(task);
      assertEquals("TASK Z TIMEREM", task.getName());

      JobQuery jobQuery = activitiRule.getManagementService().createJobQuery().processInstanceId(processInstance.getId());
      assertEquals(1, jobQuery.count());

      activitiRule.getProcessEngine().getProcessEngineConfiguration().getClock().setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 6000)));
      JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 6000L, 25L);
      assertEquals(0L, jobQuery.count());

      Task taskAfterJob = activitiRule.getTaskService().createTaskQuery().processInstanceId(processInstance.getProcessInstanceId()).singleResult();
      assertNotNull(taskAfterJob);
      assertEquals("TASK PO TIMERZE", taskAfterJob.getName());
   }




   <?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:xsd="http://www.w3.org/2001/XMLSchema" 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="PROCES_Z_TIMEREM" name="PROCES Z TIMEREM 2" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <userTask id="usertask1" name="TASK Z TIMEREM"></userTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="usertask1"></sequenceFlow>
    <boundaryEvent id="boundarytimer1" name="Timer" attachedToRef="usertask1" cancelActivity="true">
      <timerEventDefinition>
        <timeDuration>PT3S</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <userTask id="usertask2" name="NIEWIDOCZNY TASK"></userTask>
    <sequenceFlow id="flow2" sourceRef="usertask1" targetRef="usertask2"></sequenceFlow>
    <userTask id="usertask3" name="TASK PO TIMERZE"></userTask>
    <sequenceFlow id="flow3" sourceRef="boundarytimer1" targetRef="usertask3"></sequenceFlow>
    <endEvent id="endevent1" name="End"></endEvent>
    <sequenceFlow id="flow4" sourceRef="usertask2" targetRef="endevent1"></sequenceFlow>
    <sequenceFlow id="flow5" sourceRef="usertask3" targetRef="endevent1"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_PROCES_Z_TIMEREM">
    <bpmndi:BPMNPlane bpmnElement="PROCES_Z_TIMEREM" id="BPMNPlane_PROCES_Z_TIMEREM">
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="160.0" y="250.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask1" id="BPMNShape_usertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="250.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="boundarytimer1" id="BPMNShape_boundarytimer1">
        <omgdc:Bounds height="30.0" width="30.0" x="310.0" y="280.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask2" id="BPMNShape_usertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="520.0" y="240.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="usertask3" id="BPMNShape_usertask3">
        <omgdc:Bounds height="55.0" width="105.0" x="272.0" y="376.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="555.0" y="386.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow1" id="BPMNEdge_flow1">
        <omgdi:waypoint x="195.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="250.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow2" id="BPMNEdge_flow2">
        <omgdi:waypoint x="355.0" y="267.0"></omgdi:waypoint>
        <omgdi:waypoint x="520.0" y="267.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow3" id="BPMNEdge_flow3">
        <omgdi:waypoint x="325.0" y="310.0"></omgdi:waypoint>
        <omgdi:waypoint x="324.0" y="376.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow4" id="BPMNEdge_flow4">
        <omgdi:waypoint x="572.0" y="295.0"></omgdi:waypoint>
        <omgdi:waypoint x="572.0" y="386.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow5" id="BPMNEdge_flow5">
        <omgdi:waypoint x="377.0" y="403.0"></omgdi:waypoint>
        <omgdi:waypoint x="555.0" y="403.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>

1 REPLY 1

jbarrez
Star Contributor
Star Contributor
The job executor polls every 5 seconds by default. Most likely you're just in  between 2 subsequent pollings.
If you change the wait time to 10seconds, it runs green:

JobTestHelper.waitForJobExecutorToProcessAllJobs(activitiRule, 10000L, 25L);