它重载了方法usingJobData(),如下图:
JobDetail job = newJob(StatefulDumbJob.class)
.withIdentity("statefulJob1", "group1")
.usingJobData(StatefulDumbJob.EXECUTION_DELAY, 10000L)//传递数据
.build();
SimpleTrigger trigger = newTrigger()
.withIdentity("trigger1", "group1")
.startAt(startTime)
.withSchedule(simpleSchedule()
.withIntervalInSeconds(3)
.repeatForever())
.build();
Date ft = sched.scheduleJob(job, trigger);
log.error("任务key: "+job.getKey() + ",执行运行时间: " + sdf.format(ft) +
",触发器重复执行次数: " + trigger.getRepeatCount() +
",触发器执行时间: " + trigger.getRepeatInterval() / 1000 + " seconds");
在任务类一样可取出:
JobDataMap map = context.getJobDetail().getJobDataMap();
int executeCount = 0;
if (map.containsKey(NUM_EXECUTIONS)) {
executeCount = map.getInt(NUM_EXECUTIONS);
}
executeCount++;
map.put(NUM_EXECUTIONS, executeCount);
大小: 11.6 KB
分享到:
2011-08-10 16:27
浏览 8813
评论
1 楼
小鸟的饥渴
2015-05-26
[color=brown][/color]trtyrytryt