I'm working on a spring project that has n maven jobs. I have a cron expression for any job. I want to check if a job is already running before I create a new cron job. How can I do that?
I take one job to show you an example. In quartz-context.xml I define the beans, set the cron expression property that takes the value from a properties file, the group property, and the job detail that is a class used to set the job parameters. This is the class:
public class DataImportJobDetail extends AbstractJobDetail {
@Override
protected JobParameters setupJobParameters(JobParameters jobParameters,
JobExecutionContext context, String jobName) {
JobParametersBuilder builder = new JobParametersBuilder(jobParameters);
builder.addString(ConfigManager.PARAM_MODE, ConfigManager.MODE_PERSIST);
return builder.toJobParameters();
}
}
I think I have to create a control here by getting the currently executing jobs list and compare it with the jobName
?