cancel
Showing results for 
Search instead for 
Did you mean: 

Timer Start Event behaviour

smirzai
Champ on-the-rise
Champ on-the-rise
Hi
I am not sure if this is the normal behavior or a bug.

I have attached the sample.

I assume it should execute the service task after 1 second  and not before. Am I right ?


Saeid
14 REPLIES 14

frederikherema1
Star Contributor
Star Contributor
That's the idea of a timer start-event. How do you atually test the behaviour? Do you have a unit-test for it?

smirzai
Champ on-the-rise
Champ on-the-rise
sure
I have attached it. its a maven small project.

smirzai
Champ on-the-rise
Champ on-the-rise
Shall I create an Issue in Jira ?

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
No, not yet. Please wait what the outcome of the testcase is.

frederikherema1
Star Contributor
Star Contributor
No really sure what your issue is? You have a process that starts a new instance every (!) second… A service-tak that throws exceptions when executed more than once. And you assert the timing is accurate between 1000 and 1050 millis. Please bare in mind that the jobexecutor TRIES to be accurate. To save resources, the scannin for jobs in the near future is done with a variable amount of time, to prevent endless polling and useless CPU-usage (environment-friedly Smiley Wink). So it makes sense that, when first job is executed, a delay of a second or so can occur.

smirzai
Champ on-the-rise
Champ on-the-rise
Hi
The point is not the accuracy. it passes the mentioned accuracy.
I don't start a new instance each second. See the main test method:

// make sure the time2 in TaskRepeatAware is null
          TaskRepeatAware.time2 = null;

// record time
  time0 = System.currentTimeMillis();
   
// prepare process. Just once, no repeating. I promise 
  prepareProcess("diagrams/timer/TimerCatcher.bpmn20.xml", "TimerCatcher");
  System.out.println("Started.                             Time = " + System.currentTimeMillis());

  // wait enough for the timer start catcher
  Thread.sleep(2000);

  // it never reaches here. because the timer event is called two times and exception is thrown

  // if successful make sure the timer has been fired in acceptable time range
  long timeDiff = TaskRepeatAware.time2 - time0;
  System.out.println("TimeDiff = " + timeDiff);
  assertTrue("Time does not comply", (timeDiff > 1000)
    && (timeDiff < 1050));


where am I creating a new instance each second ?

another proof, just put some system.out.print(System.currentTimeMillis()) in TaskRepeatAware.execute and delete the rest, increase the sleep in above code to say 10 seconds and rerun the test. you will see that the execute method  is called just two times, not one each second,  one just at the start of the process and the other one seconds later. the first call is the culprit.

neither <timeDuration>PT1S</timeDuration> does not include "R/" for reoccurance.

– saeid

frederikherema1
Star Contributor
Star Contributor
I see… Thanks for clarifying. Seems like a genuine bug worth investigating further. Can you create a JIRA issue, attach the project and link to the forum-post? That would be very kind/helpful Smiley Wink

smirzai
Champ on-the-rise
Champ on-the-rise

smirzai
Champ on-the-rise
Champ on-the-rise
When I was checking this problem, I faced another problem.
I expect the start timer event be started  after I start the instance. Right now, the timer job starts after deployment and before starting the instance.
Is this expected or is it a bug ?

– Saeid