Interface Scheduler.JobDefinition
- Enclosing interface:
Scheduler
No job is scheduled until the setTask(Consumer) or setAsyncTask(Function) method is called.
The implementation is not thread-safe and should not be reused.
-
Method Summary
Modifier and TypeMethodDescriptionschedule()Attempts to schedule the job.setAsyncTask(Class<? extends Function<ScheduledExecution, io.smallrye.mutiny.Uni<Void>>> asyncTaskClass) The class must either represent a CDI bean or declare a public no-args constructor.setAsyncTask(Function<ScheduledExecution, io.smallrye.mutiny.Uni<Void>> asyncTask) setConcurrentExecution(Scheduled.ConcurrentExecution concurrentExecution) The schedule is defined either bysetCron(String)or bysetInterval(String).setDelayed(String period) setExecuteWith(String implementation) setInterval(String every) The schedule is defined either bysetCron(String)or bysetInterval(String).setOverdueGracePeriod(String period) setSkipPredicate(Scheduled.SkipPredicate skipPredicate) setSkipPredicate(Class<? extends Scheduled.SkipPredicate> skipPredicateClass) default Scheduler.JobDefinitionsetTask(Class<? extends Consumer<ScheduledExecution>> taskClass) The class must either represent a CDI bean or declare a public no-args constructor.setTask(Class<? extends Consumer<ScheduledExecution>> consumerClass, boolean runOnVirtualThread) The class must either represent a CDI bean or declare a public no-args constructor.default Scheduler.JobDefinitionsetTask(Consumer<ScheduledExecution> task) setTask(Consumer<ScheduledExecution> task, boolean runOnVirtualThread) Configures the task to schedule.setTimeZone(String timeZone)
-
Method Details
-
setCron
The schedule is defined either bysetCron(String)or bysetInterval(String). If both methods are used, then the cron expression takes precedence.- Parameters:
cron-- Returns:
- self
- See Also:
-
setInterval
The schedule is defined either bysetCron(String)or bysetInterval(String). If both methods are used, then the cron expression takes precedence.A value less than one second may not be supported by the underlying scheduler implementation. In that case a warning message is logged immediately.
- Parameters:
every-- Returns:
- self
- See Also:
-
setDelayed
- Parameters:
period-- Returns:
- self
- See Also:
-
setConcurrentExecution
- Parameters:
concurrentExecution-- Returns:
- self
- See Also:
-
setSkipPredicate
- Parameters:
skipPredicate-- Returns:
- self
- See Also:
-
setSkipPredicate
Scheduler.JobDefinition setSkipPredicate(Class<? extends Scheduled.SkipPredicate> skipPredicateClass) - Parameters:
skipPredicateClass-- Returns:
- self
- See Also:
-
setOverdueGracePeriod
- Parameters:
period-- Returns:
- self
- See Also:
-
setTimeZone
- Returns:
- self
- See Also:
-
setExecuteWith
- Parameters:
implementation-- Returns:
- self
- Throws:
IllegalArgumentException- If the composite scheduler is used and the selected implementation is not available- See Also:
-
setTask
- Parameters:
task-- Returns:
- self
-
setTask
The class must either represent a CDI bean or declare a public no-args constructor.In case of CDI, there must be exactly one bean that has the specified class in its set of bean types. The scope of the bean must be active during execution of the job. If the scope is
Dependentthen the bean instance belongs exclusively to the specific job definition and is destroyed when the application is shut down. If the bean is not a dependency of any other bean it has to be marked as unremovable; for example annotated withUnremovable.In case of a class with public no-args constructor, the constructor must be registered for reflection when an application is compiled to a native executable; for example annotate the class with
RegisterForReflection.- Parameters:
taskClass-- Returns:
- self
-
setTask
Configures the task to schedule.- Parameters:
task- the task, must not benullrunOnVirtualThread- whether the task must be run on a virtual thread if the JVM allows it.- Returns:
- self
-
setTask
Scheduler.JobDefinition setTask(Class<? extends Consumer<ScheduledExecution>> consumerClass, boolean runOnVirtualThread) The class must either represent a CDI bean or declare a public no-args constructor.In case of CDI, there must be exactly one bean that has the specified class in its set of bean types. The scope of the bean must be active during execution of the job. If the scope is
Dependentthen the bean instance belongs exclusively to the specific job definition and is destroyed when the application is shut down. If the bean is not a dependency of any other bean it has to be marked as unremovable; for example annotated withUnremovable.In case of a class with public no-args constructor, the constructor must be registered for reflection when an application is compiled to a native executable; for example annotate the class with
RegisterForReflection.- Parameters:
consumerClass-runOnVirtualThread-- Returns:
- self
-
setAsyncTask
Scheduler.JobDefinition setAsyncTask(Function<ScheduledExecution, io.smallrye.mutiny.Uni<Void>> asyncTask) - Parameters:
asyncTask-- Returns:
- self
-
setAsyncTask
Scheduler.JobDefinition setAsyncTask(Class<? extends Function<ScheduledExecution, io.smallrye.mutiny.Uni<Void>>> asyncTaskClass) The class must either represent a CDI bean or declare a public no-args constructor.In case of CDI, there must be exactly one bean that has the specified class in its set of bean types. The scope of the bean must be active during execution of the job. If the scope is
Dependentthen the bean instance belongs exclusively to the specific job definition and is destroyed when the application is shut down. If the bean is not a dependency of any other bean it has to be marked as unremovable; for example annotated withUnremovable.In case of a class with public no-args constructor, the constructor must be registered for reflection when an application is compiled to a native executable; for example annotate the class with
RegisterForReflection.- Parameters:
asyncTaskClass-- Returns:
- self
-
schedule
Trigger schedule()Attempts to schedule the job.- Returns:
- the trigger
-