Annotation Interface Job


Allows to add a specific name to a job that will be used in the dashboard as well as extra jobFilters that will be used for the job. The annotation can be used on the method that is referenced in the lambda.
An example:
      public class MyService {

          @Job(name = "Doing some work", jobFilters = {TheSunIsAlwaysShiningElectStateFilter.class, TestFilter.class})
          public void doWork() {
              // some long running task
          }
      }

      MyService service = new MyService();
      BackgroundJob.enqueue(() -> service.doWork());
 

In the Job name you can also reference parameters which where passed to the method. This is done by means of the syntax %{index} where index is the zero-based index of your parameters.

An example:
       public class MyService {

           @Job(name = "Doing some work for user %0", jobFilters = {TheSunIsAlwaysShiningElectStateFilter.class, TestFilter.class})
           public void doWork(String userName) {
               // some long running task
           }
       }

       MyService service = new MyService();
       BackgroundJob.enqueue(() -> service.doWork("Ronald"));
  
  • Field Details

    • NBR_OF_RETRIES_NOT_PROVIDED

      static final int NBR_OF_RETRIES_NOT_PROVIDED
      See Also:
  • Element Details

    • name

      String name
      The name of the job. Parameter substitution is supported by means of %0 (this will be replaced by the toString representation of the first argument).
      Returns:
      the name of the job.
      Default:
      ""
    • retries

      int retries
      Default:
      -1
    • labels

      String[] labels
      The labels for the job. Parameter substitution is supported by means of %0 (this will be replaced by the toString representation of the first argument).
      Returns:
      the labels for the job.
      Default:
      {}
    • jobFilters

      Class<? extends JobFilter>[] jobFilters
      Default:
      {}