Closed
Description
openedon Oct 23, 2024
Description
Considering a clustered setup of Quartz, the need for a recurrent task to be triggered only once its previous execution is terminated can be addressed using the programmatic way i.e. the Quartz API.
final JobDetail job = JobBuilder.newJob(MyTask.class).withIdentity(identity, group).build();
final Trigger trigger = TriggerBuilder.newTrigger()
.withIdentity(identity, group)
.withSchedule(CronScheduleBuilder.cronSchedule(cron))
.build();
scheduler.schedule(job, trigger);
@DisallowConcurrentExecution
public static final class MyTask implements Job {
@Override
public void execute(JobExecutionContext context) {
// my work
}
}
The declarative way i.e. the @Scheduled
annotation is still limited, because its concurrentExecution
attribute manages non-concurrency locally on a single node i.e. a single application instance, but not globally, considering every nodes i.e. every application instances.
Therefore, the request is to provide an equivalent solution design using the declarative way i.e. an annotation like the @scheduled one.
Implementation ideas
- To bridge the
@DisallowedConcurrentExecution
annotation and theconcurrentExecution=SKIP
attribute of the @scheduled annotation. - To design another annotation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment