Reputation: 131
I am using resilience4j Library for fault tolerance with Spring Boot. I want to maintain resilience4j configuration in application.yml file.
I want to use resilience 4j annotations as it helps to keep the business logic clean.
But in cases where the annotations do not work(like AOP does not allow calling methods of the same class and not being able to annotate Spring data repository methods) I want to use the functional programming approach .
For the configuration given in application.yml file , how do I create CircuitBreaker and Retry beans in my Spring boot applications so that I can decorate calls with high order functional programming in some scenarios and use annotations in other.
My current configuration:
resilience4j:
retry:
configs:
default:
max-retry-attempts: 3
wait-duration: 5s
retry-exception-predicate: com.example.resilience.predicate.RetryExceptionPredicate
retry-exceptions:
- java.io.IOException
- java.util.concurrent.TimeoutException
instances:
ierp-test:
base-config: default
Upvotes: 1
Views: 624
Reputation: 37034
Such configuration will wrap circuitbreaker over retry
resilience4j:
retry:
retry-aspect-order: 2
instances:
myRertry:
...
circuitbreaker:
circuit-breaker-aspect-order: 1
instances:
myCircuitBreaker:
...
Upvotes: 0