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

  1. @Client("/pets")
  2. @Retryable
  3. public interface PetClient extends PetOperations {
  4. @Override
  5. Single<Pet> save(String name, int age);
  6. }

Declaring @Retryable

  1. @Client("/pets")
  2. @Retryable
  3. interface PetClient extends PetOperations {
  4. @Override
  5. Single<Pet> save(String name, int age)
  6. }

Declaring @Retryable

  1. @Client("/pets")
  2. @Retryable
  3. interface PetClient : PetOperations {
  4. override fun save(name: String, age: Int): Single<Pet>
  5. }

For more information on customizing retry, see the section on Retry Advice.