Annotation Type Task


  • @Target(METHOD)
    @Retention(RUNTIME)
    @Inherited
    @Documented
    public @interface Task
    Allows to add a specific name to a task that will be used in the dashboard as well as extra taskFilters that will be used for the task. The annotation can be used on the method that is referenced in the lambda.

    An example:

          public class MyService {
    
              @Task(name = "Doing some work", taskFilters = {TheSunIsAlwaysShiningElectStateFilter.class, TestFilter.class})
              public void doWork() {
                  // some long running task
              }
          }
    
          MyService service = new MyService();
          BackgroundTask.enqueue(() -> service.doWork());
     

    In the Task 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 {
    
               @Task(name = "Doing some work for user %0", taskFilters = {TheSunIsAlwaysShiningElectStateFilter.class, TestFilter.class})
               public void doWork(String userName) {
                   // some long running task
               }
           }
    
           MyService service = new MyService();
           BackgroundTask.enqueue(() -> service.doWork("Ronald"));
      
    • Field Detail

      • NBR_OF_RETRIES_NOT_PROVIDED

        static final int NBR_OF_RETRIES_NOT_PROVIDED
    • Element Detail

      • name

        String name
        Default:
        ""
      • retries

        int retries
        Default:
        -1