Timer events execution is too slow

Hi,
I have a small bpmn process with start timer event, script task and end event. The properties of the start timer are :

R/PT1S

I use Spring boot to deploy the process. The problem which I am facing is that the timer execution is too slow. It is supposed to be 1 sec, but in reality is about 7 seconds. Can you give me an explanation about this behavior?
Thank you,
Ani

Hi Ani,

protected int defaultTimerJobAcquireWaitTimeInMillis = 10 * 1000;

Means that timers are acquired with 10 sec period. You can change this value. I would recommend to do not use such a short timers. BPM processes are long running. For testing I prefer time manipulations.

org.flowable.engine.test.bpmn.event.timer.StartTimerEventTest#testDurationStartTimerEvent
@Deployment
public void testDurationStartTimerEvent() throws Exception {

    // Set the clock fixed
    Date startTime = new Date();

    // After process start, there should be timer created
    TimerJobQuery jobQuery = managementService.createTimerJobQuery();
    assertEquals(1, jobQuery.count());

    // After setting the clock to time '50 minutes and 5 seconds', the second timer should fire
    processEngineConfiguration.getClock().setCurrentTime(new Date(startTime.getTime() + ((50 * 60 * 1000) + 5000)));
    waitForJobExecutorToProcessAllJobs(5000L, 200L);

    List<ProcessInstance> pi = runtimeService.createProcessInstanceQuery().processDefinitionKey("startTimerEventExample").list();
    assertEquals(1, pi.size());

    assertEquals(0, jobQuery.count());

}

Regards
Martin

1 Like

Martin,
thank you for the reply and your advice. I found in the flowable docs that we can change some of the default values for the job executor. I tried to change the default value of flowable.process.async.executor.default-timer-job-acquire-wait-time-in-millis in application properties, but nothing changed.
Regards,
Ani

Hi Ani,

The problem with 1s period could be that job could be still executed when it should be fetched again.
The best way to really find out what is going on is to debug the behaviour in the simple test.

Martin

Which value did you put in there? What do you mean by nothing changed?

In the docs it says that the default value for flowable.process.async.executor.default-timer-job-acquire-wait-time-in-millis is 10 seconds. I tried to change it to 1 second (1000 millis), but the the process started in more than 7 seconds even though the timer was set to start in 1 second.

Do you have a simple unit test that demonstrates this? We’re using the exact same setup in the unit tests and we don’t see delays there.

Capture

<startEvent id="startEvent" isInterrupting="true">
  <timerEventDefinition>
    <timeCycle>R5/PT1S</timeCycle>
  </timerEventDefinition>
</startEvent>
<scriptTask id="scriptTask" name="Script task" scriptFormat="groovy" flowable:autoStoreVariables="false">
  <script><![CDATA[out:println "Hello!"]]></script>
</scriptTask>
<endEvent id="endEvent"></endEvent> 

This is my application properties file:

flowable.process.async.executor.default-timer-job-acquire-wait-time-in-millis=1000

And this is my main class where I call the process using startProcessInstanceByKey from RuntimeService:

@Bean
CommandLineRunner init(final RuntimeService runtimeService) {
return new CommandLineRunner() {

		public void run(String... args) throws Exception {

			runtimeService.startProcessInstanceByKey("test");

		}

	};
}