Annotation Type ApplyFaultTolerance
-
@Inherited @Documented @Retention(RUNTIME) @Target({METHOD,TYPE}) @InterceptorBinding @Experimental("first attempt at providing reusable fault tolerance strategies") public @interface ApplyFaultTolerance
A special interceptor binding annotation to apply preconfigured fault tolerance. If@ApplyFaultTolerance("<identifier>")is present on a business method, then a bean of typeFaultTolerancewith qualifier@Identifier("<identifier>")must exist. Such bean serves as a preconfigured set of fault tolerance strategies and is used to guard invocations of the annotated business method(s).It is customary to create such bean by declaring a
staticproducer field. That removes all scoping concerns, because only one instance ever exists. Using a non-static producer field or a producer method means that scoping must be carefully considered, especially if stateful fault tolerance strategies are configured.The
@ApplyFaultToleranceannotation may also be present on a bean class, in which case it applies to all business methods declared by the class. If the annotation is present both on the method and the class declaring the method, the one on the method takes precedence.When
@ApplyFaultToleranceapplies to a business method, all other fault tolerance annotations that would otherwise also apply to that method are ignored.A single preconfigured fault tolerance can be applied to multiple methods, as long as asynchrony of all those methods is the same as the asynchrony of the fault tolerance instance. For example, if the fault tolerance instance is created using
FaultTolerance.create(), it can be applied to all synchronous methods, but not to any asynchronous method. If the fault tolerance instance is created usingFaultTolerance.createAsync(), it can be applied to all asynchronous methods that returnCompletionStage, but not to synchronous methods or asynchronous methods that return any other asynchronous type.A single preconfigured fault tolerance can even be applied to multiple methods with different return types, as long as the constraint on method asynchrony described above is obeyed. In such case, it is customary to declare the fault tolerance instance as
FaultTolerance<Object>for synchronous methods,FaultTolerance<CompletionStage<Object>>for asynchronous methods that returnCompletionStage, and so on. Note that this effectively precludes defining a useful fallback, because fallback can only be defined when the value type is known.
-
-
Element Detail
-
value
String value
The identifier of a preconfigured fault tolerance instance.
-
-