akloaklo
Supremacy Member
- Joined
- Nov 15, 2004
- Messages
- 7,265
- Reaction score
- 23
Hey guys,
I'm currently doing a task application for my company with java and encountered another problem but i'm not sure if it is common to encounter it.
I'm using SPRING framework for the easy to use @scheduler annotation,
I tested a method to run every min. Just a simple db query + logging and nothing else.
It is critical for me to get this right but the timer seemed inconsistent.
For example the output in my log:
Method ran @ 2014-03-06 16:50:00.668 (4:50:00pm 668 millisecs)
Method ran @ 2014-03-06 16:51:00.002
Method ran @ 2014-03-06 16:51:59.887
Notice the problem here?
The first 2 were the expected output, millisecond doesn't concern me as long as the minutes+seconds are correct but look at the 3rd example, suddenly the minutes/seconds is wrong due the slower milliseconds. Now this is giving me problem as i'm not sure if it is suppose to be like this.
I'm using @schedule(cron= 0 * * * * *) //Runs every min forever
Basically the above is just a crontab that specific to run every min forever.
Although i'm not familiar with crontab, it seemed from my output that it is correct but some how the millisecond is not consistent.
The first thing that came to mind is to just add some method to round up/round down the milliseconds if it is not at 00 seconds and google seemed to support that. Anyway i'm wondering if that is the expected behavior or not?
Any one with inputs? Not looking for solution but feel free to suggest what to do.
Just want to know if it is a known problem with the timer or is it with spring framework.
I'm currently doing a task application for my company with java and encountered another problem but i'm not sure if it is common to encounter it.
I'm using SPRING framework for the easy to use @scheduler annotation,
I tested a method to run every min. Just a simple db query + logging and nothing else.
It is critical for me to get this right but the timer seemed inconsistent.
For example the output in my log:
Method ran @ 2014-03-06 16:50:00.668 (4:50:00pm 668 millisecs)
Method ran @ 2014-03-06 16:51:00.002
Method ran @ 2014-03-06 16:51:59.887
Notice the problem here?
The first 2 were the expected output, millisecond doesn't concern me as long as the minutes+seconds are correct but look at the 3rd example, suddenly the minutes/seconds is wrong due the slower milliseconds. Now this is giving me problem as i'm not sure if it is suppose to be like this.
I'm using @schedule(cron= 0 * * * * *) //Runs every min forever
Basically the above is just a crontab that specific to run every min forever.
Although i'm not familiar with crontab, it seemed from my output that it is correct but some how the millisecond is not consistent.
The first thing that came to mind is to just add some method to round up/round down the milliseconds if it is not at 00 seconds and google seemed to support that. Anyway i'm wondering if that is the expected behavior or not?
Any one with inputs? Not looking for solution but feel free to suggest what to do.
Just want to know if it is a known problem with the timer or is it with spring framework.
Last edited: