AnsweredAssumed Answered

Timer example in activitirc1

Question asked by parul_vipparthi on Nov 28, 2010
Latest reply on Mar 1, 2016 by jbarrez
Hello

I have been trying the Timer example. I am really very confused now and i am really sorry to ask such basic questions in the forum. but please help me.

This is the code in bpmn file (bundled with examples)


<boundaryEvent id="escalationTimer" cancelActivity="true" attachedToRef="firstLineSupport">
   <timerEventDefinition>
      <timeDuration>PT8S</timeDuration>
   </timerEventDefinition>
</boundaryEvent>
I just changed the time duration to 8 seconds
As per the above code I would expect the second line support to be available in 8 seconds.
but this works only if i manually execute the job using managementService.executeJob(timer.getId());
If instead i dont execute the job and keep the process alive using Thread.sleep(10000) then can i expect secondline support after 10 seconds?
here is the changed code

public void testInterruptingTimerDuration() {

   // Start process instance
   ProcessInstance pi = runtimeService.startProcessInstanceByKey("escalationExample");

   // There should be one task, with a timer : first line support
   Task task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
   assertEquals("First line support", task.getName());
   //taskService.complete(task.getId());
   // Manually execute the job
   Job timer = managementService.createJobQuery().singleResult();
   try {
      Thread.sleep(10000);
   } catch (InterruptedException e) {
      System.out.println("time elapsed");
   }
   // managementService.executeJob(timer.getId());
   // The timer has fired, and the second task (secondlinesupport) now exists
   task = taskService.createTaskQuery().processInstanceId(pi.getId()).singleResult();
   System.out.println("task "+ task.getName());
}
The above code prints "First line support".
I am sorry if my concepts are wrong here. but please help.

Thank you
parul

Outcomes