Search in sources :

Example 66 with StdSchedulerFactory

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);
    }
}
Also used : StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) JobKey(org.quartz.JobKey) JobDataMap(org.quartz.JobDataMap) JobDetail(org.quartz.JobDetail) Trigger(org.quartz.Trigger) SchedulerException(org.quartz.SchedulerException) StdSchedulerFactory(org.quartz.impl.StdSchedulerFactory) SchedulerFactory(org.quartz.SchedulerFactory)

Aggregations

StdSchedulerFactory (org.quartz.impl.StdSchedulerFactory)66 SchedulerFactory (org.quartz.SchedulerFactory)29 SchedulerException (org.quartz.SchedulerException)22 Scheduler (org.quartz.Scheduler)19 JobDetail (org.quartz.JobDetail)17 Logger (org.slf4j.Logger)14 Date (java.util.Date)11 Properties (java.util.Properties)11 Trigger (org.quartz.Trigger)11 JobKey (org.quartz.JobKey)7 JobDataMap (org.quartz.JobDataMap)6 TriggerBuilder.newTrigger (org.quartz.TriggerBuilder.newTrigger)5 InputStream (java.io.InputStream)4 Test (org.junit.Test)4 DateBuilder.nextGivenSecondDate (org.quartz.DateBuilder.nextGivenSecondDate)4 SimpleTrigger (org.quartz.SimpleTrigger)4 ParseException (java.text.ParseException)3 CronTrigger (org.quartz.CronTrigger)3 SimpleThreadPool (org.quartz.simpl.SimpleThreadPool)3 QuartzManager (com.example.quartz.QuartzManager)2