Java Code Examples for org.quartz.Scheduler#pauseTrigger()

The following examples show how to use org.quartz.Scheduler#pauseTrigger() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DataBaseSchedulerFactoryBean.java    From jeecg with Apache License 2.0 6 votes vote down vote up
/**
	 * 读取数据库判断是否开始定时任务
	 */
	public void afterPropertiesSet() throws Exception {
		super.afterPropertiesSet();

//		String[] trigerrNames = this.getScheduler().getTriggerNames(Scheduler.DEFAULT_GROUP);
		Scheduler scheduler = this.getScheduler();
		List<String> trigerrNames = scheduler.getTriggerGroupNames();
		TSTimeTaskEntity task;
		
		for (String trigerrName : trigerrNames) {
			task = timeTaskService.findUniqueByProperty(TSTimeTaskEntity.class,"taskId",trigerrName);
			//数据库查询不到的定时任务或者定时任务的运行状态不为1时,都停止
			//TASK #327 定时器任务默认未启动 
			if(task==null || !"1".equals(task.getIsStart())){
//				this.getScheduler().pauseTrigger(trigerrName,Scheduler.DEFAULT_GROUP);
				scheduler.pauseTrigger(new TriggerKey(trigerrName));
			}

		}
	}
 
Example 2
Source File: QuartzManagerUtils.java    From kafka-eagle with Apache License 2.0 5 votes vote down vote up
/** Remove job. */
public static void removeJob(String jobName) {
	try {
		Scheduler sched = schedulerFactory.getScheduler();
		TriggerKey triggerKey = TriggerKey.triggerKey("ke_trigger_name_" + new Date().getTime(), "ke_trigger_group_" + new Date().getTime());
		sched.pauseTrigger(triggerKey);
		sched.unscheduleJob(triggerKey);
		sched.deleteJob(JobKey.jobKey(jobName, KE_JOB_GROUP_NAME));
	} catch (Exception e) {
		throw new RuntimeException(e);
	}
}
 
Example 3
Source File: ScheduleServiceImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
public void suspendTrigger(String triggerName, String triggerGroup) {
	if(!getIsEnabled()){
		throw new FixFlowScheduleException(ExceptionCode.QUARZTEXCEPTION_ISENABLE);
	}
	Scheduler scheduler = getScheduler();
	TriggerKey tKey = new TriggerKey(triggerName,triggerGroup);
	try {
		scheduler.pauseTrigger(tKey);
	} catch (SchedulerException e) {
		throw new FixFlowException(e.getMessage(),e);
	}
}
 
Example 4
Source File: QuartzUtils.java    From quartz-web with Apache License 2.0 4 votes vote down vote up
public static void pauseTrigger(String triggerName, String triggerGroup, Scheduler scheduler) throws SchedulerException {
    TriggerKey triggerKey = getTriggerKey(triggerName, triggerGroup);
    scheduler.pauseTrigger(triggerKey);
}
 
Example 5
Source File: QuartzUtils.java    From quartz-web with Apache License 2.0 2 votes vote down vote up
/**
 * 暂停Trigger
 * @param trigger
 * @param scheduler
 * @throws SchedulerException
 */
public static void pauseTrigger(Trigger trigger, Scheduler scheduler) throws SchedulerException {
    scheduler.pauseTrigger(trigger.getKey());
}