Annotation Type AsynchronousNonBlocking


@Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @InterceptorBinding @Inherited @Experimental("second attempt at better handling of blocking/non-blocking asynchrony") public @interface AsynchronousNonBlocking
Alternative to MicroProfile Fault Tolerance's @Asynchronous for guarding non-blocking asynchronous methods (executed on the original thread). It may only be present on methods that declare return type of CompletionStage. Other than that, it has the same meaning as MicroProfile Fault Tolerance's @Asynchronous. More specifically:

When a method marked with this annotation is called, the method call is allowed to proceed on the original thread. It is assumed that the guarded method will, at some point, perform some non-blocking asynchronous operation(s), such as non-blocking IO, and that it synchronously returns a CompletionStage. It is further assumed that the completion of the asynchronous non-blocking operation(s) executed by the guarded method is followed by completion of the returned CompletionStage.

When the guarded method returns, a CompletionStage is returned to the caller and can be used to access the result of the asynchronous execution, when it completes.

Before the asynchronous execution completes, the CompletionStage returned to the caller is incomplete. Once the asynchronous execution completes, the CompletionStage returned to the caller becomes equivalent to the CompletionStage returned by the guarded method. If the guarded method synchronously throws an exception, the returned CompletionStage completes with that exception.

If a method marked with this annotation doesn't declare return type of CompletionStage, FaultToleranceDefinitionException occurs during deployment.

If a class is annotated with this annotation, all its methods are treated as if they were marked with this annotation. If one of the methods doesn't return CompletionStage, FaultToleranceDefinitionException occurs during deployment.