use of org.quartz.Trigger in project camel by apache.
the class QuartzNameCollisionTest method testRemoveJob.
/**
* Confirm the quartz trigger is removed on route stop.
*/
@Test
public void testRemoveJob() throws Exception {
camel1 = new DefaultCamelContext();
camel1.setName("camel-1");
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup/myTimerName?cron=0/1+*+*+*+*+?").id("route-1").to("log:one", "mock:one");
}
});
camel1.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("quartz2://myGroup2/myTimerName?cron=0/1+*+*+*+*+?").id("route-2").to("log:one", "mock:one");
}
});
camel1.start();
QuartzComponent component = (QuartzComponent) camel1.getComponent("quartz2");
Scheduler scheduler = component.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey("myTimerName", "myGroup");
Trigger trigger = scheduler.getTrigger(triggerKey);
Assert.assertNotNull(trigger);
camel1.stopRoute("route-1");
Trigger.TriggerState triggerState = component.getScheduler().getTriggerState(triggerKey);
Assert.assertNotNull(trigger);
Assert.assertEquals(Trigger.TriggerState.PAUSED, triggerState);
}
use of org.quartz.Trigger in project camel by apache.
the class QuartzSimpleRouteTest 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 SimpleTrigger, 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("simple"), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_COUNTER).equals(-1), CoreMatchers.is(true));
Assert.assertThat(detail.getJobDataMap().get(QuartzConstants.QUARTZ_TRIGGER_SIMPLE_REPEAT_INTERVAL).equals(2000L), CoreMatchers.is(true));
}
use of org.quartz.Trigger in project camel by apache.
the class QuartzStatefulJobRouteTest 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(StatefulCamelJob.class), CoreMatchers.is(true));
}
use of org.quartz.Trigger in project jforum2 by rafaelsteil.
the class POPJobStarter method startJob.
public static void startJob() throws SchedulerException {
boolean isEnabled = SystemGlobals.getBoolValue(ConfigKeys.MAIL_POP3_INTEGRATION_ENABLED);
if (!isStarted && isEnabled) {
String filename = SystemGlobals.getValue(ConfigKeys.QUARTZ_CONFIG);
String cronExpression = SystemGlobals.getValue("org.quartz.context.mailintegration.cron.expression");
scheduler = new StdSchedulerFactory(filename).getScheduler();
Trigger trigger = null;
try {
trigger = new CronTrigger(POPListener.class.getName(), "pop3Integration", cronExpression);
logger.info("Starting POP3 integration expression " + cronExpression);
scheduler.scheduleJob(new JobDetail(POPListener.class.getName(), "pop3Integration", POPListener.class), trigger);
scheduler.start();
} catch (ParseException e) {
e.printStackTrace();
}
}
isStarted = true;
}
use of org.quartz.Trigger in project jforum2 by rafaelsteil.
the class SummaryScheduler method startJob.
/**
* Starts the summary Job. Conditions to start: Is not started yet and is enabled on the file
* SystemGlobasl.properties. The to enable it is "summary.enabled"
* (ConfigKeys.SUMMARY_IS_ENABLED).
*
* @throws SchedulerException
* @throws IOException
*/
public static void startJob() throws SchedulerException {
boolean isEnabled = SystemGlobals.getBoolValue(ConfigKeys.SUMMARY_IS_ENABLED);
if (!isStarted && isEnabled) {
String filename = SystemGlobals.getValue(ConfigKeys.QUARTZ_CONFIG);
String cronExpression = SystemGlobals.getValue("org.quartz.context.summary.cron.expression");
scheduler = new StdSchedulerFactory(filename).getScheduler();
Trigger trigger = null;
try {
trigger = new CronTrigger(SummaryJob.class.getName(), "summaryJob", cronExpression);
logger.info("Starting quartz summary expression " + cronExpression);
scheduler.scheduleJob(new JobDetail(SummaryJob.class.getName(), "summaryJob", SummaryJob.class), trigger);
scheduler.start();
} catch (ParseException e) {
e.printStackTrace();
}
}
isStarted = true;
}
Aggregations