/** |
* Quartz Cron 表达式支持到七个域 名称 是否必须 允许值 特殊字符 秒 是 0-59 , - * / 分 是 0-59 , - * / |
* 时 是 0-23 , - * / 日 是 1-31 , - * ? / L W C 月 是 1-12或 JAN-DEC , - * / 周 是 |
* 1-7 或 SUN-SAT , - * ? / L C # 年 否 空 或 1970-2099 , - * / |
* |
* @param Properties |
*/ |
private boolean initTimePaln() { |
Properties prams = Config.getInstance().getMqPrams(); |
if (prams == null ) { |
logger.error( "MQ配置信息为空" ); |
} |
int timePlan = Integer.parseInt(prams.getProperty( "PLANTIME" )); |
int timePlan_refreshCache = Integer.parseInt(prams |
.getProperty( "TIMEPLAN_REFRESHCACHE" )); |
try { |
Properties props = new Properties(); |
props.put(StdSchedulerFactory.PROP_THREAD_POOL_CLASS, |
"org.quartz.simpl.SimpleThreadPool" ); |
props.put( "org.quartz.threadPool.threadCount" , "3" ); |
SchedulerFactory sf = new StdSchedulerFactory(props); |
if (timePlan != - 1 ) { |
CronTrigger trigger = newTrigger() |
.withIdentity( "TimePlanTrigger" , "group1" ) |
.withSchedule( |
cronSchedule( "0 1 " + timePlan + " * * ?" )) |
.build(); |
JobDetail job = newJob(CallDataTramsfromTask. class ) |
.withIdentity( "TimpPlanJob" , "group1" ).build(); |
scheduler_TimePlan = sf.getScheduler(); |
Date ft = scheduler_TimePlan.scheduleJob(job, trigger); |
logger.info(job.getKey() + "在" + ft + "开始调度执行,调度周期为" |
+ trigger.getCronExpression()); |
} |
if (timePlan_refreshCache != - 1 ) { |
CronTrigger trigger_refreshCachfe = newTrigger() |
.withIdentity( "TimePlanTrigger_refreshCache" , |
"group3" ) |
.withSchedule( |
cronSchedule( "0 1 " + timePlan_refreshCache |
+ " * * ?" )).build(); |
JobDetail job__refreshCachfe = newJob(RefreshCacheTask. class ) |
.withIdentity( "TimpPlanJob_refreshCache" , "group3" ) |
.build(); |
Date ft = scheduler_TimePlan.scheduleJob(job__refreshCachfe, |
trigger_refreshCachfe); |
logger.info(job__refreshCachfe.getKey() + "在" + ft |
+ "开始调度执行(刷新缓存),调度周期为" |
+ trigger_refreshCachfe.getCronExpression()); |
} |
} catch (SchedulerException e) { |
logger.error( "初始化定时调度器异常" + e.getMessage()); |
return false ; |
} |
return true ; |
} |