This issue is to discuss the opportunity to share the code suggested in jmrozanec/cron-utils#491 within this module.
The pull requests has been closed because the functionality is more related to this extension module.
@jmrozanec : I checked the code in detail and found the following really important difference in the design of both solutions.
Your approach: Jobs a managed by additional polling thead(s) that check the trigger (usually by calling ExecutionTime.forCron(cron).nextExecution(ZonedDateTime.now()))
Our approach: Use ScheduledExecutorService.schedule() by calculating a "delay":
...
private ZonedDateTime nextExecution;
...
/**
* Plans the next execution time to run this job again.
*
* @param timeStamp the reference time stamp
*/
private void scheduleNext(final ZonedDateTime timeStamp) {
final Optional<ZonedDateTime> next = executionTime.nextExecution(timeStamp);
if (next.isPresent()) {
nextExecution = next.get();
final long delay = ChronoUnit.MILLIS.between(timeStamp, nextExecution);
scheduledFuture = executorService.schedule(this, delay, TimeUnit.MILLISECONDS);
} else {
// job maybe defined to run only once
scheduledFuture = null;
}
}
Advantage:
- It's more lightweight and simple in general
- No extra polling threads needed
Disadvantage:
- No concept for more general Execution trigger
- Scheduling of jobs other than calculated by
Cron expressions maybe out-of-scope
So my question:
Is scheduling of non-Cron based jobs really a requirement?
If yes I would think our approach does not fit or can only be provided in addition to the current one.
If no I would suggest to re-code the scheduling using "our" approach.
Please let me know how we should go on!
And please be aware: No rush! This task will be done by me in my "private time" anyway ;-).
This issue is to discuss the opportunity to share the code suggested in jmrozanec/cron-utils#491 within this module.
The pull requests has been closed because the functionality is more related to this extension module.
@jmrozanec : I checked the code in detail and found the following really important difference in the design of both solutions.
Your approach: Jobs a managed by additional polling thead(s) that check the trigger (usually by calling
ExecutionTime.forCron(cron).nextExecution(ZonedDateTime.now()))Our approach: Use
ScheduledExecutorService.schedule()by calculating a "delay":Advantage:
Disadvantage:
Cronexpressions maybe out-of-scopeSo my question:
Is scheduling of non-
Cronbased jobs really a requirement?If yes I would think our approach does not fit or can only be provided in addition to the current one.
If no I would suggest to re-code the scheduling using "our" approach.
Please let me know how we should go on!
And please be aware: No rush! This task will be done by me in my "private time" anyway ;-).