AnsweredAssumed Answered

Timer not working with SpringBoot

Question asked by deb99s on Dec 14, 2014
Latest reply on Dec 16, 2014 by deb99s
I am developing an Activiti prototype using Spring Boot with Spring MVC/Thymeleaf and Security with Java 1.7 and Eclipse.  It is very simple and follows the Spring Boot example.  The flow immediately goes to a subprocess with a user task and a boundary timer.  The timer is created, but never executes.  In Application.java in the main class the JobExecutorActivate is set to true.  I have tried putting the flow definition in /processes and loading it specifically from another subdirectory.


   public static void main(String[] args) {
      ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);
      ProcessEngine processEngine = context.getBean(ProcessEngine.class);
      ProcessEngineConfiguration processEngineConfiguration = processEngine.getProcessEngineConfiguration();
           log.info("activate timers=" + processEngineConfiguration.isJobExecutorActivate() + "," + processEngineConfiguration);
      processEngineConfiguration.setJobExecutorActivate(true);



This is logged:

   The timer is inserted:  Preparing: insert into ACT_RU_JOB ( ID_ ….


Why is the timer not activating?

Any help would be very appreciated!


Here is my flow definition:

<xml>
<?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" xmlns:modeler="http://activiti.com/modeler" typeLanguage="http://www.w3.org/2001/XMLSchema" expressionLanguage="http://www.w3.org/1999/XPath" targetNamespace="http://www.activiti.org/processdef" modeler:version="1.0ev" modeler:exportDateTime="20141205204706" modeler:modelId="924356" modeler:modelVersion="1" modeler:modelLastUpdated="1417812416137">
  <process id="timerTestFlow" name="timerTestFlow" isExecutable="true">
    <extensionElements>
      <activiti:executionListener event="start" expression="activiti:expression=&quot;${selector.logMsg('Job flow started')}&quot;"></activiti:executionListener>
    </extensionElements>
    <startEvent id="startJobCreateWF" name="startJobCreateWFTask">
    </startEvent>
    <sequenceFlow id="flow18" sourceRef="startJobCreateWF" targetRef="subprocess1"></sequenceFlow>
    <subProcess id="subprocess1" name="Sub Process">
      <startEvent id="startevent1" name="Start"></startEvent>
      <userTask id="flowusertask1" name="Flow User Task"></userTask>
      <sequenceFlow id="flow20" sourceRef="startevent1" targetRef="flowusertask1"></sequenceFlow>
      <endEvent id="endevent1" name="End"></endEvent>
      <sequenceFlow id="flow21" sourceRef="flowusertask1" targetRef="endevent1"></sequenceFlow>
    </subProcess>
    <boundaryEvent id="mainFlowBoundarytimer1" name="MainFlowTimer" attachedToRef="subprocess1" cancelActivity="true">
      <timerEventDefinition>
        <timeDuration>PT1S</timeDuration>
      </timerEventDefinition>
    </boundaryEvent>
    <sequenceFlow id="flow22" sourceRef="mainFlowBoundarytimer1" targetRef="Timerusertask2">
      <extensionElements>
        <activiti:executionListener event="take" expression="activiti:expression=&quot;${selector.logMsg('After Timer in main flow')}&quot;"></activiti:executionListener>
      </extensionElements>
    </sequenceFlow>
    <userTask id="Timerusertask2" name="Timer User Task"></userTask>
    <endEvent id="endevent2" name="End"></endEvent>
    <sequenceFlow id="flow23" sourceRef="Timerusertask2" targetRef="endevent2"></sequenceFlow>
    <endEvent id="endevent3" name="End"></endEvent>
    <sequenceFlow id="flow24" sourceRef="subprocess1" targetRef="endevent3"></sequenceFlow>
  </process>
  <bpmndi:BPMNDiagram id="BPMNDiagram_timerTestFlow">
    <bpmndi:BPMNPlane bpmnElement="timerTestFlow" id="BPMNPlane_timerTestFlow">
      <bpmndi:BPMNShape bpmnElement="startJobCreateWF" id="BPMNShape_startJobCreateWF">
        <omgdc:Bounds height="35.0" width="35.0" x="20.0" y="108.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="subprocess1" id="BPMNShape_subprocess1">
        <omgdc:Bounds height="205.0" width="205.0" x="170.0" y="23.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="startevent1" id="BPMNShape_startevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="230.0" y="63.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="flowusertask1" id="BPMNShape_flowusertask1">
        <omgdc:Bounds height="55.0" width="105.0" x="195.0" y="126.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent1" id="BPMNShape_endevent1">
        <omgdc:Bounds height="35.0" width="35.0" x="330.0" y="136.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="mainFlowBoundarytimer1" id="BPMNShape_mainFlowBoundarytimer1">
        <omgdc:Bounds height="30.0" width="30.0" x="360.0" y="63.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="Timerusertask2" id="BPMNShape_Timerusertask2">
        <omgdc:Bounds height="55.0" width="105.0" x="510.0" y="50.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent2" id="BPMNShape_endevent2">
        <omgdc:Bounds height="35.0" width="35.0" x="890.0" y="60.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNShape bpmnElement="endevent3" id="BPMNShape_endevent3">
        <omgdc:Bounds height="35.0" width="35.0" x="420.0" y="108.0"></omgdc:Bounds>
      </bpmndi:BPMNShape>
      <bpmndi:BPMNEdge bpmnElement="flow18" id="BPMNEdge_flow18">
        <omgdi:waypoint x="55.0" y="125.0"></omgdi:waypoint>
        <omgdi:waypoint x="170.0" y="125.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow20" id="BPMNEdge_flow20">
        <omgdi:waypoint x="247.0" y="98.0"></omgdi:waypoint>
        <omgdi:waypoint x="247.0" y="126.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow21" id="BPMNEdge_flow21">
        <omgdi:waypoint x="300.0" y="153.0"></omgdi:waypoint>
        <omgdi:waypoint x="330.0" y="153.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow22" id="BPMNEdge_flow22">
        <omgdi:waypoint x="390.0" y="78.0"></omgdi:waypoint>
        <omgdi:waypoint x="510.0" y="77.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow23" id="BPMNEdge_flow23">
        <omgdi:waypoint x="615.0" y="77.0"></omgdi:waypoint>
        <omgdi:waypoint x="890.0" y="77.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
      <bpmndi:BPMNEdge bpmnElement="flow24" id="BPMNEdge_flow24">
        <omgdi:waypoint x="375.0" y="125.0"></omgdi:waypoint>
        <omgdi:waypoint x="420.0" y="125.0"></omgdi:waypoint>
      </bpmndi:BPMNEdge>
    </bpmndi:BPMNPlane>
  </bpmndi:BPMNDiagram>
</definitions>
</xml>

Here is my pom.xml:
<xml>

   <parent>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-parent</artifactId>
      <version>1.1.9.RELEASE</version>
      <relativePath />
   </parent>

   <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <start-class>com.myapp.activiti.Application</start-class>
      <java.version>1.7</java.version>
      <activiti.version>5.17.0-SNAPSHOT</activiti.version>
      <spring.boot.version>1.1.9.RELEASE</spring.boot.version>
      <guava.version>17.0</guava.version>
   </properties>

   <dependencies>

      <dependency>
         <groupId>com.h2database</groupId>
         <artifactId>h2</artifactId>
      </dependency>

      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-test</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-data-rest</artifactId>
      </dependency>
      <dependency>
         <groupId>org.springframework.boot</groupId>
         <artifactId>spring-boot-starter-web</artifactId>
      </dependency>
      <dependency>
         <groupId>org.activiti</groupId>
         <artifactId>spring-boot-starter-basic</artifactId>
         <version>${activiti.version}</version>
      </dependency>
      <dependency>
         <groupId>org.activiti</groupId>
         <artifactId>spring-boot-starter-integration</artifactId>
         <version>${activiti.version}</version>
      </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>

      <!– Activiti Dependencies –>
      <dependency>
         <groupId>org.activiti</groupId>
         <artifactId>activiti-engine</artifactId>
         <version>${activiti.version}</version>
      </dependency>
      <dependency>
         <groupId>org.activiti</groupId>
         <artifactId>activiti-spring</artifactId>
         <version>${activiti.version}</version>
      </dependency>

      <!– added –>

        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${activiti.version}</version>
        </dependency>
        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>spring-boot-starter-jpa</artifactId>
            <version>${activiti.version}</version>
        </dependency>

        <dependency>
            <groupId>org.activiti</groupId>
            <artifactId>spring-boot-starter-security</artifactId>
            <version>${activiti.version}</version>
        </dependency>
      <dependency>
         <groupId>com.google.guava</groupId>
         <artifactId>guava</artifactId>
         <version>${guava.version}</version>
      </dependency>

   </dependencies>


   <build>
      <plugins>
         <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
         </plugin>
      </plugins>
   </build>

   <repositories>
      <repository>
         <id>Activiti</id>
         <url>http://maven.alfresco.com/nexus/content/repositories/activiti</url>
      </repository>
      <repository>
         <id>Activiti Snapshot Maven Repository</id>
         <url>http://oss.sonatype.org/content/repositories/snapshots/</url>
      </repository>

   </repositories>

</project>
</xml>

Outcomes