Top Description Methods
org.springframework.scheduling.annotation

public @Interface Async

extends Annotation
Annotations
@Target:TYPE, METHOD
@Retention:RUNTIME
@Documented
@Reflective
Imports
java.lang.annotation.Documented, .ElementType, .Retention, .RetentionPolicy, .Target, org.springframework.aot.hint.annotation.Reflective

Annotation that marks a method as a candidate for asynchronous execution.

Can also be used at the type level, in which case all the type's methods are considered as asynchronous. Note, however, that @Async is not supported on methods declared within a @Configuration class.

In terms of target method signatures, any parameter types are supported. However, the return type is constrained to either void or java.util.concurrent.Future. In the latter case, you may declare the more specific org.springframework.util.concurrent.ListenableFuture or java.util.concurrent.CompletableFuture types which allow for richer interaction with the asynchronous task and for immediate composition with further processing steps.

A Future handle returned from the proxy will be an actual asynchronous Future that can be used to track the result of the asynchronous method execution. However, since the target method needs to implement the same signature, it will have to return a temporary Future handle that just passes a value through: for example, Spring's AsyncResult, EJB 3.1's jakarta.ejb.AsyncResult, or java.util.concurrent.CompletableFuture#completedFuture(Object).

Authors
Juergen Hoeller, Chris Beams
Since
3.0
See Also
AnnotationAsyncExecutionInterceptor, AsyncAnnotationAdvisor

Method Summary

Modifier and TypeMethod and Description
public String
value()

A qualifier value for the specified asynchronous operation(s).

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

valueback to summary
public String value()

A qualifier value for the specified asynchronous operation(s).

May be used to determine the target executor to be used when executing the asynchronous operation(s), matching the qualifier value (or the bean name) of a specific Executor or TaskExecutor bean definition.

When specified in a class-level @Async annotation, indicates that the given executor should be used for all methods within the class. Method-level use of Async#value always overrides any qualifier value configured at the class level.

The qualifier value will be resolved dynamically if supplied as a SpEL expression (for example, "#{environment['myExecutor']}") or a property placeholder (for example, "${my.app.myExecutor}").

Since
3.1.2