Trigger
Trigger
is a component defines the schedule upon which a given Job
will be executed.
There are different types of triggers that you can select from to meet different scheduling needs.
There are some advanced configurations to enforce complex scheduling recurrences
In order to help humans understand the configuration of triggers, you can utilize its representation.
Shutdown trigger
There are several ways to cancel the trigger
-
By a specific
repeat
configuration inIntervalTrigger
-
By
until
configuration inTriggerRule
-
By marking
cancel
flag in the job execution
@Source
public class CancelTriggerInJob implements Job<Void, Void> {
@Override
public void execute(@NotNull JobData<Void> jobData, @NotNull ExecutionContext<Void> executionContext) {
// do something
// ...
if (executionContext.round() == 10) {
executionContext.forceStopExecution();
}
}
}
-
By manual
cancel
inScheduler
CronTrigger trigger = CronTrigger.builder().expression("0 0/3 0 ? * * *").build(); (1)
CronScheduler scheduler = CronScheduler.<Void, Void>builder() (2)
.setVertx(vertx).setTrigger(trigger).setJob(job).build();
// Start scheduler
scheduler.start(); (3)
// Do other stuff
// ...
// after a while later, you can cancel the `scheduler`.
// And the `trigger` is no longer to fire in the future.
scheduler.cancel(); (4)