use of org.quartz.impl.StdSchedulerFactory in project siddhi by wso2.
the class CronWindowProcessor method scheduleCronJob.
private void scheduleCronJob(String cronString) {
try {
SchedulerFactory schedFact = new StdSchedulerFactory();
scheduler = schedFact.getScheduler();
jobName = siddhiQueryContext.getName() + "_EventRemoverJob_" + siddhiQueryContext.generateNewId();
JobKey jobKey = new JobKey(jobName, jobGroup);
if (scheduler.checkExists(jobKey)) {
scheduler.deleteJob(jobKey);
}
scheduler.start();
JobDataMap dataMap = new JobDataMap();
dataMap.put("windowProcessor", this);
JobDetail job = org.quartz.JobBuilder.newJob(CronWindowProcessor.class).withIdentity(jobName, jobGroup).usingJobData(dataMap).build();
Trigger trigger = org.quartz.TriggerBuilder.newTrigger().withIdentity("EventRemoverTrigger_" + id, jobGroup).withSchedule(CronScheduleBuilder.cronSchedule(cronString)).build();
scheduler.scheduleJob(job, trigger);
} catch (SchedulerException e) {
log.error("Error while instantiating quartz scheduler", e);
}
}
Aggregations