cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Catching Event is executing only once even when Interval is Set

piyush_kaizen
Champ in-the-making
Champ in-the-making
Hi,
What is wrong with the following process definition

<process id="timer_catching_event" name="My process" isExecutable="true">
    <endEvent id="endevent1" name="End"></endEvent>
    <startEvent id="startevent1" name="Start"></startEvent>
    <intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
      <timerEventDefinition>
        <timeCycle>R4/PT10S</timeCycle>
      </timerEventDefinition>
    </intermediateCatchEvent>
    <scriptTask id="scripttask1" name="Script Task" scriptFormat="javascript" activiti:autoStoreVariables="false">
      <script>java.lang.System.out.println("Script Task in Timer Catching Example Executed");
java.lang.System.out.println("Time of Execution");
java.lang.System.out.println(JSON.stringify(new Date()));</script>
    </scriptTask>
    <sequenceFlow id="flow1" sourceRef="startevent1" targetRef="timerintermediatecatchevent1"></sequenceFlow>
    <sequenceFlow id="flow2" sourceRef="timerintermediatecatchevent1" targetRef="scripttask1"></sequenceFlow>
    <sequenceFlow id="flow3" sourceRef="scripttask1" targetRef="endevent1"></sequenceFlow>
  </process>


The script task is executing only once.
7 REPLIES 7

cjose
Elite Collaborator
Elite Collaborator
The script will execute only once based on your bpmn20.xml. If you want some looping logic with a time delay, you will need to implement the loop in your bpmn diagram and exit out of the loop based on a loop counter stored in a variable. Another option is to group the activities in your loop in a sub-process and configure the multi-instance properties on the sub-process (http://www.activiti.org/userguide/#bpmnMultiInstance) according to your requirement.

Regards,
Ciju

piyush_kaizen
Champ in-the-making
Champ in-the-making
Thanks cjose,

But Then I don't understand what does "R4/PT10S" would do.
As far as I know R4 means repetition.
What would it repeat then ?

cjose
Elite Collaborator
Elite Collaborator
"R4/PT10S" is the notation of repeatability. However I don't think it can be used with an intermediate timer event.

Ciju

piyush_kaizen
Champ in-the-making
Champ in-the-making
Thanks cjose,
Can you specify  where repeatability is allowed and where not
Eg. In Timer Start Event, Timer Boundary Event and Timer Catching Event …

vasile_dirla
Star Contributor
Star Contributor
Him piyush,

intermediate timer events are acting like "stopwatch"
see details here:
http://www.activiti.org/userguide/#bpmnTimerIntermediateEvent
http://www.activiti.org/userguide/#timerEventDefinitions

Another good source of examples is the tests we have in the source code. (inspecting these tests you can learn a lot of things about how Activiti is expected to work)

piyush_kaizen
Champ in-the-making
Champ in-the-making
Thanks vasile.dirla ,
My question is Timer Catching events don't reoccur if i set Time Cycle as "R4/PT10S".

vasile_dirla
Star Contributor
Star Contributor
Hi Piyush,

Yes, you are right the R is ignored in case of an intermediate catch event of type timer. (because the purpose of the intermediate catching event of type timer is to act as a stopwatch.)

so this construction:

<code>
<intermediateCatchEvent id="timerintermediatecatchevent1" name="TimerCatchEvent">
<timerEventDefinition>
<timeCycle>R4/PT10S</timeCycle>
</timerEventDefinition>
</intermediateCatchEvent>
</code>

will ignore the "R4" part of the definition.