I have created a job status table where i have a boolean flag based on that i am returning the cron expreesion(active cron or hypen(-) cron) and my scheduler will work. Boolean flag will be updated if you want to enable or disable all spring batch jobs.
How can we contol the flag in the application otherwise we will have issues in running the cron expression?
@Scheduled(cron = "#{@getCronValueDevice}")
@Scheduled(cron = "#{@getCronValueStorage}")
@Bean
public String getCronValueDevice() {
JobStatus jobStatus = jobStatusRepository.findByJobName(BatchJobConstants.DEVICE_JOB_NAME);
if (jobStatus != null && jobStatus.getIsActive()) {
return jobStatus.getActiveCronExpression();
} else {
return "-";
}