| | |
| | | package com.doumee.dao.timer.scheduler; |
| | | |
| | | import com.doumee.core.constants.ResponseStatus; |
| | | import com.doumee.core.exception.BusinessException; |
| | | import com.doumee.dao.timer.entity.JobState; |
| | | import com.doumee.dao.timer.entity.QuartzJob; |
| | | import org.quartz.*; |
| | |
| | | CronScheduleBuilder scheduleBuilder = CronScheduleBuilder |
| | | .cronSchedule(quartzJob.getCronExpres()) |
| | | .withMisfireHandlingInstructionDoNothing(); |
| | | // 任务触发器 |
| | | CronTrigger trigger = getCronTrigger(quartzJob.getId()) |
| | | .getTriggerBuilder().withIdentity(triggerKey) |
| | | .withSchedule(scheduleBuilder).build(); |
| | | trigger.getJobDataMap().put(QuartzJob.JOB_PARAM_KEY, quartzJob); |
| | | scheduler.rescheduleJob(triggerKey, trigger); |
| | | // 状态校验 |
| | | checkStop(quartzJob) ; |
| | | CronTrigger t = getCronTrigger(quartzJob.getId()); |
| | | if(t !=null){ |
| | | // 任务触发器 |
| | | CronTrigger trigger = t |
| | | .getTriggerBuilder().withIdentity(triggerKey) |
| | | .withSchedule(scheduleBuilder).build(); |
| | | trigger.getJobDataMap().put(QuartzJob.JOB_PARAM_KEY, quartzJob); |
| | | scheduler.rescheduleJob(triggerKey, trigger); |
| | | // 状态校验 |
| | | checkStop(quartzJob) ; |
| | | } |
| | | |
| | | } catch (SchedulerException e) { |
| | | throw new RuntimeException("updateJob Fail",e) ; |
| | | } |
| | |
| | | this.scheduler.pauseJob(getJobKey(quartzJob.getId())); |
| | | } |
| | | } catch (SchedulerException e){ |
| | | throw new RuntimeException("pauseJob Fail",e) ; |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"pauseJob Fail",e) ; |
| | | } |
| | | } |
| | | |