SmallRye Fault Tolerance Documentation
SmallRye Fault Tolerance 6.7.1 is an implementation of Eclipse MicroProfile Fault Tolerance 4.1.1 with additional features not defined by the specification.
It provides a declarative, annotation-based API for guarding method calls:
@ApplicationScoped
public class MyService {
@Retry (1)
public String hello() {
...
}
}
1 | If hello() throws an exception, the invocation will be retried several times, until the method returns a value. |
It also provides a programmatic API to build reusable guards:
public class MyService {
private static final TypedGuard<String> GUARD = TypedGuard.create(String.class)
.withFallback().handler(() -> "fallback").done() (1)
.build();
public String hello() throws Exception {
return GUARD.call(() -> externalService.hello()); (2)
}
}
1 | If the guarded call throws an exception, the fallback value will be returned instead. |
2 | The guarded call simply invokes some external service. |
The fault tolerance strategies provided by SmallRye Fault Tolerance are best suited for guarding network interactions.
To handle ordinary exceptions, it is typically best to use the plain old try / catch / finally blocks.
Using SmallRye Fault Tolerance as a replacement of exception handling is often a bad idea.
|
Some additional features may have experimental status, marked by the @Experimental annotation.
The programmatic API to build reusable guards, as mentioned above, is one example, but there are more.
|
Navigation
This documentation site has several sections, as you can see in the menu.
How-to Guides
How-tos are task-oriented guides that let you quickly start using some feature. They provide a short overview, but not many details.
If you’re just starting with SmallRye Fault Tolerance, start with the how-tos. |
References
References are detailed guides that let you understand some feature in depth. They also provide information about more advanced options or features.
If the how-to guide doesn’t answer a question you have, the reference guide should. |