Interface Scheduler.JobDefinition<THIS extends Scheduler.JobDefinition<THIS>>

Enclosing interface:
Scheduler

public static interface Scheduler.JobDefinition<THIS extends Scheduler.JobDefinition<THIS>>
The job definition is a builder-like API that can be used to define a job programmatically.

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 Details

    • setCron

      THIS setCron(String cron)
      The schedule is defined either by setCron(String) or by setInterval(String). If both methods are used, then the cron expression takes precedence.

      Scheduled.cron()

      Parameters:
      cron -
      Returns:
      self
      See Also:
    • setInterval

      THIS setInterval(String every)
      The schedule is defined either by setCron(String) or by setInterval(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.

      Scheduled.every()

      Parameters:
      every -
      Returns:
      self
      See Also:
    • setDelayed

      THIS setDelayed(String period)
      Parameters:
      period -
      Returns:
      self
      See Also:
    • setConcurrentExecution

      THIS setConcurrentExecution(Scheduled.ConcurrentExecution concurrentExecution)
      Parameters:
      concurrentExecution -
      Returns:
      self
      See Also:
    • setSkipPredicate

      THIS setSkipPredicate(Scheduled.SkipPredicate skipPredicate)
      Parameters:
      skipPredicate -
      Returns:
      self
      See Also:
    • setSkipPredicate

      THIS setSkipPredicate(Class<? extends Scheduled.SkipPredicate> skipPredicateClass)
      Parameters:
      skipPredicateClass -
      Returns:
      self
      See Also:
    • setOverdueGracePeriod

      THIS setOverdueGracePeriod(String period)
      Parameters:
      period -
      Returns:
      self
      See Also:
    • setTimeZone

      THIS setTimeZone(String timeZone)
      Returns:
      self
      See Also:
    • setExecuteWith

      THIS setExecuteWith(String implementation)
      Parameters:
      implementation -
      Returns:
      self
      Throws:
      IllegalArgumentException - If the composite scheduler is used and the selected implementation is not available
      See Also:
    • setExecutionMaxDelay

      THIS setExecutionMaxDelay(String maxDelay)
      Parameters:
      maxDelay -
      Returns:
      self
      See Also:
    • setTask

      default THIS setTask(Consumer<ScheduledExecution> task)
      Parameters:
      task -
      Returns:
      self
    • setTask

      default THIS setTask(Class<? extends Consumer<ScheduledExecution>> taskClass)
      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 Dependent then 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 with Unremovable.

      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

      THIS setTask(Consumer<ScheduledExecution> task, boolean runOnVirtualThread)
      Configures the task to schedule.
      Parameters:
      task - the task, must not be null
      runOnVirtualThread - 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 Dependent then 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 with Unremovable.

      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

      THIS setAsyncTask(Function<ScheduledExecution,io.smallrye.mutiny.Uni<Void>> asyncTask)
      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 Dependent then 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 with Unremovable.

      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