use of org.springframework.scheduling.quartz.SimpleTriggerFactoryBean in project netxms by netxms.
the class QuartzReportScheduler method execute.
@Override
public UUID execute(UUID jobId, int userId, UUID reportUuid, Map<String, Object> parameters) {
if (jobId == null) {
jobId = UUID.randomUUID();
}
log.debug("New job " + jobId + " for report " + reportUuid);
String groupName = reportUuid.toString();
JobDetailFactoryBean jobDetailFactory = new JobDetailFactoryBean();
jobDetailFactory.setName(jobId.toString());
jobDetailFactory.setGroup(groupName);
jobDetailFactory.setJobClass(GeneratorJob.class);
jobDetailFactory.afterPropertiesSet();
JobDetail jobDetail = jobDetailFactory.getObject();
final JobDataMap dataMap = jobDetail.getJobDataMap();
dataMap.put("jobId", jobId);
dataMap.put("reportId", reportUuid);
dataMap.put("parameters", parameters);
dataMap.put("userId", userId);
SimpleTriggerFactoryBean triggerFactoryBean = new SimpleTriggerFactoryBean();
triggerFactoryBean.setName(jobId.toString() + "_trigger");
triggerFactoryBean.setGroup(groupName);
triggerFactoryBean.setJobDetail(jobDetail);
triggerFactoryBean.setRepeatCount(0);
triggerFactoryBean.afterPropertiesSet();
Trigger trigger = triggerFactoryBean.getObject();
try {
scheduler.scheduleJob(jobDetail, trigger);
} catch (SchedulerException e) {
log.error("Can't schedule job", e);
jobId = null;
}
return jobId;
}
use of org.springframework.scheduling.quartz.SimpleTriggerFactoryBean in project tutorials by eugenp.
the class SpringQrtzScheduler method trigger.
@Bean
public SimpleTriggerFactoryBean trigger(JobDetail job) {
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setJobDetail(job);
int frequencyInSec = 10;
logger.info("Configuring trigger to fire every {} seconds", frequencyInSec);
trigger.setRepeatInterval(frequencyInSec * 1000);
trigger.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
trigger.setName("Qrtz_Trigger");
return trigger;
}
use of org.springframework.scheduling.quartz.SimpleTriggerFactoryBean in project openolat by klemens.
the class SchedulerTest method testSimpleTrigger.
@Test
public void testSimpleTrigger() throws SchedulerException, ParseException {
JobDetail job = newJob(SchedulerTestJob.class).withIdentity("schedulerTestJobSimpleTrigger", Scheduler.DEFAULT_GROUP).build();
SimpleTriggerFactoryBean trigger = new SimpleTriggerFactoryBean();
trigger.setName("Test scheduler trigger");
trigger.setStartDelay(0);
trigger.setRepeatInterval(1000);
trigger.setRepeatCount(10);
trigger.setJobDetail(job);
trigger.afterPropertiesSet();
// Schedule job now
scheduler.scheduleJob(job, trigger.getObject());
// because of cal.add(Calendar.MILLISECOND, 11);
sleep(20);
// check number of calls to the job
org.quartz.Calendar quartzCal = scheduler.getCalendar(trigger.getObject().getCalendarName());
Calendar cal = Calendar.getInstance();
Date start = cal.getTime();
cal.add(Calendar.SECOND, 5);
cal.add(Calendar.MILLISECOND, 11);
Date end = cal.getTime();
Assert.assertEquals(5, TriggerUtils.computeFireTimesBetween((OperableTrigger) trigger.getObject(), quartzCal, start, end).size());
}
use of org.springframework.scheduling.quartz.SimpleTriggerFactoryBean in project simba-os by cegeka.
the class TriggerConfiguration method createSimpleTrigger.
private SimpleTriggerFactoryBean createSimpleTrigger(JobDetail jobDetail, long repeatIntervalInMillis) {
SimpleTriggerFactoryBean bean = new SimpleTriggerFactoryBean();
bean.setJobDetail(jobDetail);
bean.setGroup(SIMBA_QUARTZ_GROUP);
bean.setRepeatCount(REPEAT_FOREVER);
bean.setRepeatInterval(repeatIntervalInMillis);
return bean;
}
Aggregations