Interface Scheduler.JobDefinition<THIS extends Scheduler.JobDefinition<THIS>>
- 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) setExecutionMaxDelay(String maxDelay) 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 THISsetTask(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 THISsetTask(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
- 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:
-
setExecutionMaxDelay
- Parameters:
maxDelay-- Returns:
- self
- 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
THIS 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
- Parameters:
asyncTask-- Returns:
- self
-
setAsyncTask
THIS 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
-