use of org.quartz.Trigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureGroupAndName.
@Test
public void testConfigureGroupAndName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz://myGroup/myName?trigger.repeatCount=3");
Trigger trigger = endpoint.getTrigger();
assertEquals("getName()", "myName", trigger.getName());
assertEquals("getGroup()", "myGroup", trigger.getGroup());
// default job name
assertEquals("getJobName", "quartz-" + endpoint.getId(), endpoint.getJobName());
SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
}
use of org.quartz.Trigger in project camel by apache.
the class QuartzMessage method populateInitialHeaders.
@Override
protected void populateInitialHeaders(Map<String, Object> map) {
super.populateInitialHeaders(map);
if (jobExecutionContext != null) {
map.put("calendar", jobExecutionContext.getCalendar());
map.put("fireTime", jobExecutionContext.getFireTime());
map.put("jobDetail", jobExecutionContext.getJobDetail());
map.put("jobInstance", jobExecutionContext.getJobInstance());
map.put("jobRunTime", jobExecutionContext.getJobRunTime());
map.put("mergedJobDataMap", jobExecutionContext.getMergedJobDataMap());
map.put("nextFireTime", jobExecutionContext.getNextFireTime());
map.put("previousFireTime", jobExecutionContext.getPreviousFireTime());
map.put("refireCount", jobExecutionContext.getRefireCount());
map.put("result", jobExecutionContext.getResult());
map.put("scheduledFireTime", jobExecutionContext.getScheduledFireTime());
map.put("scheduler", jobExecutionContext.getScheduler());
Trigger trigger = jobExecutionContext.getTrigger();
map.put("trigger", trigger);
map.put("triggerName", trigger.getKey().getName());
map.put("triggerGroup", trigger.getKey().getGroup());
}
}
use of org.quartz.Trigger in project camel by apache.
the class CronScheduledRoutePolicy method createTrigger.
@Override
protected Trigger createTrigger(Action action, Route route) throws Exception {
Trigger trigger = null;
CronScheduleBuilder scheduleBuilder = null;
String triggerPrefix = null;
if (action == Action.START) {
scheduleBuilder = CronScheduleBuilder.cronSchedule(getRouteStartTime());
triggerPrefix = TRIGGER_START;
} else if (action == Action.STOP) {
scheduleBuilder = CronScheduleBuilder.cronSchedule(getRouteStopTime());
triggerPrefix = TRIGGER_STOP;
} else if (action == Action.SUSPEND) {
scheduleBuilder = CronScheduleBuilder.cronSchedule(getRouteSuspendTime());
triggerPrefix = TRIGGER_SUSPEND;
} else if (action == Action.RESUME) {
scheduleBuilder = CronScheduleBuilder.cronSchedule(getRouteResumeTime());
triggerPrefix = TRIGGER_RESUME;
}
if (scheduleBuilder != null) {
if (timeZone != null) {
scheduleBuilder.inTimeZone(timeZone);
}
TriggerKey triggerKey = new TriggerKey(triggerPrefix + route.getId(), TRIGGER_GROUP + route.getId());
trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
}
return trigger;
}
use of org.quartz.Trigger in project camel by apache.
the class QuartzCronRouteTest method testQuartzCronRoute.
@Test
public void testQuartzCronRoute() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(3);
assertMockEndpointsSatisfied();
Trigger trigger = mock.getReceivedExchanges().get(0).getIn().getHeader("trigger", Trigger.class);
Assert.assertThat(trigger instanceof CronTrigger, CoreMatchers.is(true));
JobDetail detail = mock.getReceivedExchanges().get(0).getIn().getHeader("jobDetail", JobDetail.class);
Assert.assertThat(detail.getJobClass().equals(CamelJob.class), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_TYPE).equals("cron"), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_CRON_EXPRESSION).equals("0/2 * * * * ?"), CoreMatchers.is(true));
}
use of org.quartz.Trigger in project camel by apache.
the class QuartzEndpointConfigureTest method testConfigureGroupAndName.
@Test
public void testConfigureGroupAndName() throws Exception {
QuartzEndpoint endpoint = resolveMandatoryEndpoint("quartz2://myGroup/myName?trigger.repeatCount=3&trigger.repeatInterval=1000");
Scheduler scheduler = endpoint.getComponent().getScheduler();
TriggerKey triggerKey = endpoint.getTriggerKey();
Trigger trigger = scheduler.getTrigger(triggerKey);
JobDetail jobDetail = scheduler.getJobDetail(JobKey.jobKey(triggerKey.getName(), triggerKey.getGroup()));
assertEquals("getName()", "myName", triggerKey.getName());
assertEquals("getGroup()", "myGroup", triggerKey.getGroup());
assertEquals("getJobName", "myName", jobDetail.getKey().getName());
assertEquals("getJobGroup", "myGroup", jobDetail.getKey().getGroup());
SimpleTrigger simpleTrigger = assertIsInstanceOf(SimpleTrigger.class, trigger);
assertEquals("getRepeatCount()", 3, simpleTrigger.getRepeatCount());
}
Aggregations