Search in sources :

Example 1 with QuartzComponent

use of org.apache.camel.component.quartz.QuartzComponent in project camel by apache.

the class CronScheduledRoutePolicy method doOnInit.

protected void doOnInit(Route route) throws Exception {
    QuartzComponent quartz = route.getRouteContext().getCamelContext().getComponent("quartz", QuartzComponent.class);
    setScheduler(quartz.getScheduler());
    if (getRouteStopGracePeriod() == 0) {
        setRouteStopGracePeriod(10000);
    }
    if (getTimeUnit() == null) {
        setTimeUnit(TimeUnit.MILLISECONDS);
    }
    // validate time options has been configured
    if ((getRouteStartTime() == null) && (getRouteStopTime() == null) && (getRouteSuspendTime() == null) && (getRouteResumeTime() == null)) {
        throw new IllegalArgumentException("Scheduled Route Policy for route {} has no start/stop/suspend/resume times specified");
    }
    registerRouteToScheduledRouteDetails(route);
    if (getRouteStartTime() != null) {
        scheduleRoute(Action.START, route);
    }
    if (getRouteStopTime() != null) {
        scheduleRoute(Action.STOP, route);
    }
    if (getRouteSuspendTime() != null) {
        scheduleRoute(Action.SUSPEND, route);
    }
    if (getRouteResumeTime() != null) {
        scheduleRoute(Action.RESUME, route);
    }
}
Also used : QuartzComponent(org.apache.camel.component.quartz.QuartzComponent)

Example 2 with QuartzComponent

use of org.apache.camel.component.quartz.QuartzComponent in project camel by apache.

the class SimpleScheduledRoutePolicy method doOnInit.

protected void doOnInit(Route route) throws Exception {
    QuartzComponent quartz = route.getRouteContext().getCamelContext().getComponent("quartz", QuartzComponent.class);
    setScheduler(quartz.getScheduler());
    if (getRouteStopGracePeriod() == 0) {
        setRouteStopGracePeriod(10000);
    }
    if (getTimeUnit() == null) {
        setTimeUnit(TimeUnit.MILLISECONDS);
    }
    // validate time options has been configured
    if ((getRouteStartDate() == null) && (getRouteStopDate() == null) && (getRouteSuspendDate() == null) && (getRouteResumeDate() == null)) {
        throw new IllegalArgumentException("Scheduled Route Policy for route {} has no start/stop/suspend/resume times specified");
    }
    registerRouteToScheduledRouteDetails(route);
    if (getRouteStartDate() != null) {
        scheduleRoute(Action.START, route);
    }
    if (getRouteStopDate() != null) {
        scheduleRoute(Action.STOP, route);
    }
    if (getRouteSuspendDate() != null) {
        scheduleRoute(Action.SUSPEND, route);
    }
    if (getRouteResumeDate() != null) {
        scheduleRoute(Action.RESUME, route);
    }
}
Also used : QuartzComponent(org.apache.camel.component.quartz.QuartzComponent)

Aggregations

QuartzComponent (org.apache.camel.component.quartz.QuartzComponent)2