Fast repeating Timer Event not working properly

Hello
I was trying to use camunda process engine to control my home brewing kettle and I came up to following situation:

I would like to be able to measure temperature of the brew each second. The problem is that if I set the non-interrupting timer start event to something like R/PT1S, the event doesn’t get fired once every second but it gets to a loop where it gets fired right after it is finished which means about each few millis (see the log). When I set the timer to R/PT1M the problem disappears and it gets called roughly each minute.

Process:
here you can see a test process which demonstrates the problem and isstripped form any other junk.
test1.bpmn (5.7 KB)

The JAVA code in the expression (called by the service task) only prints current date to the console.

I would like to ask whether I am missing something or if I discovered a bug? I see that in your christmas blog entry here you use PT1S successfully.

I am using camunda 7.6.0, run on wildfly shared engine.

Log:

15:11:47,498 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='65b2a4b4-d0f5-11e6-8d3c-005056c00001'
15:11:47,557 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:47 CET 2017

15:11:47,679 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='65d39a3e-d0f5-11e6-8d3c-005056c00001'
15:11:47,702 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:47 CET 2017

15:11:47,746 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='65eaf2d8-d0f5-11e6-8d3c-005056c00001'
15:11:47,816 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:47 CET 2017

15:11:47,834 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='65fca622-d0f5-11e6-8d3c-005056c00001'
15:11:47,879 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:47 CET 2017

15:11:47,891 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='66066a2c-d0f5-11e6-8d3c-005056c00001'
15:11:47,947 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:47 CET 2017

15:11:48,001 INFO  [org.camunda.bpm.engine.jobexecutor] (pool-8-thread-2) ENGINE-14008 Adding new exclusive job to job executor context. Job Id='6610ca76-d0f5-11e6-8d3c-005056c00001'
15:11:48,067 INFO  [stdout] (pool-8-thread-2) Mon Jan 02 15:11:48 CET 2017

Thank you
Adam

Hi @Adam_Klima,

Even if this looks a little bit odd, this is the intended behavior in that configuration. Let me try to explain what happens:
When you start a new instance of that process a timer job is created for the non-interrupting timer event. The process engine continues the process instance until the user task is reached. Then the changes are flushed to the database (i.e. the created job is inserted).
The job is now visible for the job executor 1. The job executor fetches and locks this job, and then it executes this job. Since this is a non-interrupting timer event a follow-up job is created with a due date (now() + 1s). This new created job will be scheduled and in 2 it checks if this new timer fires before the next time the job executor will check for new timers to fire. So in your configuration the job executor gets a hint that a new job has been created. After the execution of the first job the job executor executes the second created job, and now you have a loop.

So, what you could do is to set the time cycle further in the future (i.e. > 5s) or you could try to decrease the waitTimeInMillis 3.

Anyway, what is your use case? Why should the non-interrupting timer event fire every second? Be aware, the concept to understand behind timer events is it should be interpreted as will not fire before the duration is up rather than will fire when the duration is up 4.

Cheers,
Roman

Hi Roman,

thank you for your reply. Now I understand what going on in the process engine. My intended usecase is controlling my homebrewing equipment. I have a kettle which power output can be controlled by a REST and which gives out temperature of the brew.

I would like to use the event subprocess with non-interrupting timer start event to check the state of the kettle every second (or so) so that an operator can see it in the user interface. Second event subprocess would persist current state (each minute) in a List so that it is persisted as a process variable and so that I can view it for reference for future brews to tune up the recipes.

Currently I have it implemented without the event subprocess using java TimerService, but it is the only part of the business logic which is in the java application and not in the .bpmn process itself and that is something I don’t like.

What is your suggestion for this problem? Would you stay with the java TimerService or would you set the waitTimeInMillis to less than one second and use the event subprocess?

Thank you
Adam