Timer at StartEvent does not work

Hi, we have integrated flowable (6.4.2) in our application and we would like to use a timer event in my start event to trigger a process periodically / by a cron expression:
As a test, I created the bpmn and java program to trigger the process:

  1. The BPMN:

ScreenHunter 907 Apr. 12 15.28
<bpmn:startEvent id=“StartEvent_1” name=“StartEvent_1”>
bpmn:outgoingSequenceFlow_0p5gtdz</bpmn:outgoing>
bpmn:timerEventDefinition
<bpmn:timeCycle xsi:type=“bpmn:tFormalExpression”>R2/PT1M</bpmn:timeCycle>
</bpmn:timerEventDefinition>
</bpmn:startEvent>

  1. The Client Java Program to Start Process:

  1. The flowable.cfg.xml

After triggering the process in my client program, it’s expected that the same process will be triggered by the timer after timecycle expired (i.e. 2 times by 1 minute interval). I’ve also checked there’s no record in the table ACT_RU_TIMER_JOB related to this process.
Can you explain possible reasons, or any configuration I missed? Thanks!

Hi, you don’t need to call the startProcessInstanceByKey. The timer is scheduled as soon as the process is deployed. Check te second note on the Timer Start Event documentation

Can you verify that the two process instances were not created and completed 1 and 2 minutes after the process was deployed?

@javiaguila , thanks for the information and we’ve tested that :

  1. After deployment , Flowable will persist 1 record (i.e. 1st cycle) in ACT_RU_TIMER_JOB with due date = create date + 1 minutes

  2. We need to use management service to trigger async executor to do the job using

processEngine.getManagementService().moveTimerToExecutableJob(timer.getId());

  1. Flowable will only persist 2nd cycle record in ACT_RU_TIMER_JOB after the first cycle is completed.

My question is, is this flowable’s design that the user / application need to have their own implementation on how / when to ask managementService to do the job ?
If not, how i can ensure the asyc executor would pick up and execute the jobs automatically by due date?

No, you don’t need to call the managementService to move the job.

The async executor will look periodically for timer jobs to be run (every 10s by default, but configurable: asyncExecutorDefaultAsyncJobAcquireWaitTime). Once it finds a timer job with a dueDate before the currentDate it will create a new async job that will be afterwards picked up and run by the async executor.

Try to check if the timer job is moved to the ACT_RU_JOB table after its dueDate (+10s) and then executed. You can also monitor the number of completed process instances to check if it has been executed.

@javiaguila I’ve checked and seems that the asyc executor of another java process has picked up the jobs instead of the one deploying the bpmn

  1. TestTimer1.java - Deploy the bpmn and print outstanding timers at 40s and 70s

  2. TestTimer2.java - Simply started the process Engine (the same flowable.cfg.xml) as TestTimer1. This one would pickup and execute the job.

Not sure about the concept of async executor but these 2 processes should have their own threadpool to handle the taskes. Why TestTimer1 won’t pickup the job itself but only done by TestTimer2 ?

TestTimer1.main:

TestTimer2.main:

the asyncExecutor of any processEngine pointing to the same database can pick up any job and run it.

If you have two engines running at the same time with the same database, the first asyncExecutor that will look for timer jobs after the timer dueDate will pick up the job.