7.3.6 Retry and Circuit Breaker
Recovering from failure is critical for HTTP clients, and that is where Micronaut’s integrated Retry Advice comes in 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
@SingleResult
Publisher<Pet> save(String name, int age);
}
Declaring @Retryable
@Client("/pets")
@Retryable
interface PetClient extends PetOperations {
@Override
Mono<Pet> save(String name, int age)
}
Declaring @Retryable
@Client("/pets")
@Retryable
interface PetClient : PetOperations {
override fun save(name: String, age: Int): Mono<Pet>
}
For more information on customizing retry, see the section on Retry Advice.