RE-планирование пакетных заданий с использованием Java, CronExpression
У меня есть работа, которая выполняется в определенное время каждый день. Я должен обновить CronExpression задания, используя некоторую логику, проблема в том, что когда CronExpression обновляется, мне нужно перезапустить сервер, чтобы запустить это задание с новым временем. Как я могу перезапустить работу без перезапуска моего сервера. Я искал другую проблему, но не смог найти свое решение.
Моя работа по обновлению cronExpression для другой работы такова:
public void reSchedulerNotofocationjob(){
List<Slots> slots=config.getActiveConfiguration().getSlotDetils();
int size=slots.size();
LocalTime slotTime;
LocalTime currenttime=new LocalTime();
String cronExp;
BatchJobs batchJobs= mongoOperations.findById("5b1f69c21f74e5ecc0c607ea", BatchJobs.class);
logger.debug("batch job id and job name "+batchJobs.getId()+" and "+batchJobs.getJobName());
for(int i=0; i<size;i++){
slotTime= LocalTime.parse(slots.get(i).getSlotTime());
if(currenttime.isBefore(slotTime)){
cronExp=slotTime.getSecondOfMinute()+" "+slotTime.getMinuteOfHour()+" "+slotTime.getHourOfDay()+" * * ? *";
mongoOperations.findAndModify(new Query(Criteria.where("_id").is("5b1f69c21f74e5ecc0c607ea")), new Update().set("cronExpression", cronExp), BatchJobs.class);
break;
}else{
if(i+1<size){
slotTime= LocalTime.parse(slots.get(i+1).getSlotTime());
if(currenttime.isBefore(slotTime)){
cronExp=slotTime.getSecondOfMinute()+" "+slotTime.getMinuteOfHour()+" "+slotTime.getHourOfDay()+" * * ? *";
mongoOperations.findAndModify(new Query(Criteria.where("_id").is("5b1f69c21f74e5ecc0c607ea")), new Update().set("cronExpression", cronExp), BatchJobs.class);
break;
}
}else{
slotTime= LocalTime.parse(slots.get(0).getSlotTime());
cronExp=slotTime.getSecondOfMinute()+" "+slotTime.getMinuteOfHour()+" "+slotTime.getHourOfDay()+" * * ? *";
mongoOperations.findAndModify(new Query(Criteria.where("_id").is("5b1f69c21f74e5ecc0c607ea")), new Update().set("cronExpression", cronExp), BatchJobs.class);
break;
}
}
}
}
Как перезапустить пакетную работу..