Annotation Type Job


  • @Target(METHOD)
    @Retention(RUNTIME)
    @Inherited
    @Documented
    public @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"));
      
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.Class<? extends JobFilter>[] jobFilters  
      java.lang.String name  
      int retries  
    • Element Detail

      • name

        java.lang.String name
        Default:
        ""
      • retries

        int retries
        Default:
        10
      • jobFilters

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