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 Summary
Fields Modifier and Type Fields Description static intNBR_OF_RETRIES_NOT_PROVIDED
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element Description StringnameintretriesClass<? extends TaskFilter>[]taskFilters
-
-
-
Element Detail
-
name
String name
- Default:
- ""
-
-
-
taskFilters
Class<? extends TaskFilter>[] taskFilters
- Default:
- {}
-
-