Fallback is specified. The container
must ensure this type safety. Otherwise, IllegalArgumentException should be thrown.
public class MyService {
@Inject
OtherService otherService;
@Timeout(3000)
@Fallback(MyFallback.class)
Long getAmount() {
return otherService.getAmount() * 2;
}
}
The fallback handler implementation is shown below. The type parameter must be assignable to Long.
public class MyFallback implements FallbackHandler<Long> {
Long handle(ExecutionContext context) {
return 42;
}
}
| Modifier and Type | Method and Description |
|---|---|
| public T | Returns: the result of the fallbackthe execution context context)Handle the previous calling failure and then call alternative methods or perform any alternative operations. |
| handle | back to summary |
|---|---|
| public T handle(ExecutionContext context) Handle the previous calling failure and then call alternative methods or perform any alternative operations.
| |