cancel
Showing results for 
Search instead for 
Did you mean: 

Timer example in activitirc1

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
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
5 REPLIES 5

frederikherema1
Star Contributor
Star Contributor
Can you check your configuration and make sure the JobExecutor is enabled?

parul_vipparthi
Champ on-the-rise
Champ on-the-rise
I changed job executor to "on" in activiti.cfg.xml
Thank you … it works now!

parul

frederikherema1
Star Contributor
Star Contributor
Glad to be of service Smiley Wink

santoshpatel
Champ in-the-making
Champ in-the-making
What do you mean by this "but this works only if i manually execute the job using managementService.executeJob(timer.getId());"
In my case what I want is second job should start after the time out and I don't want to add any wait/sleep. Basically can I have the synchronous timer?

jbarrez
Star Contributor
Star Contributor
You're resurrecting a five year old thread ….
Not sure if I'm following you, but what you describe seems to be the default of having a service task after a timer?