cancel
Showing results for 
Search instead for 
Did you mean: 

problem with intermediateCatchEvent

m2spring
Champ in-the-making
Champ in-the-making
I'm trying to have a 5 seconds "sleep" task in my workflow using the http://www.activiti.org/userguide/index.html#bpmnIntermediateCatchingEvent:
[img]http://www.springdot.org/files/20121128-1306.png[/img]


<?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="wfsleep" name="WfSleep" isExecutable="true">
    <startEvent id="startevent1" name="Start"></startEvent>
    <endEvent id="endevent1" name="End"></endEvent>
    <scriptTask id="scripttask1" name="1" scriptFormat="groovy">
      <script><![CDATA[System.out.println("script task 1");]]></script>
    </scriptTask>
    <scriptTask id="scripttask2" name="Script Task" scriptFormat="groovy">
      <script><![CDATA[System.out.println("script task 2");]]></script>
    </scriptTask>
    <intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
      <timerEventDefinition>
        <timeDuration>PT5S</timeDuration>
      </timerEventDefinition>
    </intermediateCatchEvent>
    …
  </process>
  …
</definitions>
https://github.com/jenkinsci/jenkow-plugin/blob/master/activiti-tests/wfsleep/src/test/resources/dia...

The intermediateCatchEvent task never completes.

What am I doing wrong?

Here's how I invoke the workflow:
https://github.com/jenkinsci/jenkow-plugin/blob/master/activiti-tests/wfsleep/src/test/java/com/cisc...

A full Maven project to reproduce this problem in a JUnit test is here:
https://github.com/jenkinsci/jenkow-plugin/tree/master/activiti-tests/wfsleep

Thanks!
-Max
4 REPLIES 4

trademak
Star Contributor
Star Contributor
Hi Max,

This is not the best way to test functionality that use jobs (using Thread.sleep)
You can look in the Activiti unit tests how this is implemented.
But what's an easy solution for your test is to do a job query and execute the intermediate timer job.

Best regards,

m2spring
Champ in-the-making
Champ in-the-making
Hi Tijs,

my code snippet is not meant as a real test. Instead it is meant to demonstrate my problem:
I want my workflow to wait (sleep) for some time, before it automatically continues.

Looking through all the unit test code of the Activiti engine I can't find an example where the intermediateCatchEvent would be tested.

According to http://www.activiti.org/userguide/index.html#bpmnIntermediateCatchingEvent, the timer should fire after the specified internal, but this is not happening for me.

Thanks!
-Max

jbarrez
Star Contributor
Star Contributor
See https://github.com/Activiti/Activiti/blob/master/modules/activiti-engine/src/test/java/org/activiti/... for a unit test.

The class to use is the ClockUtil which changes the internal clock of the engine.

That being said, I checked your test and I saw that you are using the


ProcessEngine eng = ProcessEngineConfiguration
       .createStandaloneInMemProcessEngineConfiguration()
       .buildProcessEngine();

To get the process engine. That will give you a default engine, with the job executor disabled. The job executor is needed for timer execution. Add following line to building the process engine to make it work:


setJobExecutorActivate(true)

m2spring
Champ in-the-making
Champ in-the-making
Now it works as expected.
Thanks a lot!
-Max