/** Run immediatly and dont do that again. */ public SimpleTimer(String name) { this.trigger = TriggerBuilder.newTrigger() .withIdentity(name, Scheduler.DEFAULT_GROUP) .withSchedule( SimpleScheduleBuilder.simpleSchedule() .withMisfireHandlingInstructionFireNow()) .startNow() .build(); // new SimpleTrigger(name, Scheduler.DEFAULT_GROUP); }
/** Run once at given time... */ public SimpleTimer(String name, String group, long startTime) { this.trigger = TriggerBuilder.newTrigger() .withIdentity(name, group) .withSchedule( SimpleScheduleBuilder.simpleSchedule() .withMisfireHandlingInstructionFireNow()) .startAt(new Date(startTime)) .build(); // new SimpleTrigger(name, group, new Date(startTime)); }
public SimpleTimer(String name, long interval) { this.trigger = TriggerBuilder.newTrigger() .withIdentity(name) .withSchedule( SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(interval) .repeatForever() .withMisfireHandlingInstructionFireNow()) .build(); // .new SimpleTrigger(name, SimpleTrigger.REPEAT_INDEFINITELY, interval); }
((SimpleScheduleBuilder)sched).withMisfireHandlingInstructionFireNow(); else if(triggerMisfireInstructionConst.equals("MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT")) ((SimpleScheduleBuilder)sched).withMisfireHandlingInstructionNextWithExistingCount();
((SimpleScheduleBuilder)sched).withMisfireHandlingInstructionFireNow(); else if(triggerMisfireInstructionConst.equals("MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT")) ((SimpleScheduleBuilder)sched).withMisfireHandlingInstructionNextWithExistingCount();
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() { SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(getRepeatInterval()) .withRepeatCount(getRepeatCount()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount(); break; } return sb; }
/** * Get a {@link ScheduleBuilder} that is configured to produce a * schedule identical to this trigger's schedule. * * @see #getTriggerBuilder() */ @Override public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() { SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule() .withIntervalInMilliseconds(getRepeatInterval()) .withRepeatCount(getRepeatCount()); switch(getMisfireInstruction()) { case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount(); break; case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount(); break; } return sb; }
private Trigger buildJobTrigger(JobDetail jobDetail, ZonedDateTime startAt) { return TriggerBuilder.newTrigger() .forJob(jobDetail) .withIdentity(jobDetail.getKey().getName(), "email-triggers") .withDescription("Send Email Trigger") .startAt(Date.from(startAt.toInstant())) .withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow()) .build(); } }
private SimpleScheduleBuilder setMisfirePolicyForSimpleTrigger(SimpleScheduleBuilder simpleSchedule, String motechMisfireProperty) { Integer misfirePolicy = simpleTriggerMisfirePolicies.get(motechMisfireProperty); if (misfirePolicy == null) { misfirePolicy = SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT; } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_SMART_POLICY)) { return simpleSchedule; } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW)) { return simpleSchedule.withMisfireHandlingInstructionFireNow(); } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_IGNORE_MISFIRE_POLICY)) { return simpleSchedule.withMisfireHandlingInstructionIgnoreMisfires(); } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT)) { return simpleSchedule.withMisfireHandlingInstructionNextWithExistingCount(); } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT)) { return simpleSchedule.withMisfireHandlingInstructionNextWithRemainingCount(); } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT)) { return simpleSchedule.withMisfireHandlingInstructionNowWithExistingCount(); } if (misfirePolicy.equals(SimpleTrigger.MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT)) { return simpleSchedule.withMisfireHandlingInstructionNowWithRemainingCount(); } return simpleSchedule; }
/** * Schedules an event after a specified time with the specified interval. * * @param event event. * @param delay delay in milliseconds. * @param interval interval in milliseconds. * @return scheduled event entry. */ @Override public EventSchedulerEntry scheduleAfter(Event event, long delay, long interval) { TriggerBuilder<Trigger> builder = newTrigger(); if (delay > 0) { builder.startAt(Date.from(Instant.now().plusMillis(delay))); } if (interval > 0) { builder.withSchedule( simpleSchedule().withIntervalInMilliseconds(interval).repeatForever().withMisfireHandlingInstructionFireNow()); } return doSchedule(event, builder.build(), interval == 0); }
.withIdentity(triggerKey) .startAt(startTime) .withSchedule(simpleSchedule().withMisfireHandlingInstructionFireNow() .withRepeatCount(repeat).withIntervalInMilliseconds(interval)).modifiedByCalendar(QuartzConstants.QUARTZ_CAMEL_CUSTOM_CALENDAR); } else { .withIdentity(triggerKey) .startAt(startTime) .withSchedule(simpleSchedule().withMisfireHandlingInstructionFireNow() .withRepeatCount(repeat).withIntervalInMilliseconds(interval));
.withRepeatCount(0) .withIntervalInSeconds(0) .withMisfireHandlingInstructionFireNow();
.withSchedule( SimpleScheduleBuilder.simpleSchedule() .withMisfireHandlingInstructionFireNow()) .build();
.withSchedule( SimpleScheduleBuilder.simpleSchedule() .withMisfireHandlingInstructionFireNow()) .build();
scheduleBuilder.withMisfireHandlingInstructionIgnoreMisfires(); else if (misfirePolicy == Every.MisfirePolicy.FIRE_NOW) scheduleBuilder.withMisfireHandlingInstructionFireNow(); else if (misfirePolicy == Every.MisfirePolicy.NOW_WITH_EXISTING_COUNT) scheduleBuilder.withMisfireHandlingInstructionNowWithExistingCount();
.withIdentity("TestTrigger") .startAt(new Date(1)) .withSchedule(SimpleScheduleBuilder.simpleSchedule().withMisfireHandlingInstructionFireNow()) .build(); Scheduler scheduler = (Scheduler) applicationContext.getBean("schedulerFactory");
Trigger newTrigger = oldTriggerBuilder.usingJobData(EAGER_CALLBACK_COUNT, eagerCallback). startNow(). withSchedule(simpleSchedule().withMisfireHandlingInstructionFireNow()).build();
simpleScheduleBuilder.withMisfireHandlingInstructionFireNow();
simpleScheduleBuilder.withMisfireHandlingInstructionFireNow();
.repeatForever(); if (sch.getMisfireAction() == null || sch.getMisfireAction() == MisfireActionType.EXECUTE_IMMEDIATELY) { sb = ssb.withMisfireHandlingInstructionFireNow(); } else if (sch.getMisfireAction() == MisfireActionType.RESCHEDULE) { sb = ssb.withMisfireHandlingInstructionNextWithRemainingCount();