7.3.6 Retry and Circuit Breaker
Being able to recover from failure is critical for HTTP clients, and that is where the integrated Retry Advice included as part of Micronaut comes in really handy.
You can declare the @Retryable or @CircuitBreaker annotations on any @Client interface and the retry policy will be applied, for example:
Declaring @Retryable
@Client("/pets")
@Retryable
public interface PetClient extends PetOperations {
@Override
Single<Pet> save(String name, int age);
}
Declaring @Retryable
@Client("/pets")
@Retryable
interface PetClient extends PetOperations {
@Override
Single<Pet> save(String name, int age)
}
Declaring @Retryable
@Client("/pets")
@Retryable
interface PetClient : PetOperations {
override fun save(name: String, age: Int): Single<Pet>
}
For more information on customizing retry, see the section on Retry Advice.