1

I have a custom yml file configuration that holds the configs needed for the circuit breaker implemented in resilience4j.

resilience4j:
circuitbreaker:
instances:
serviceA:
eventConsumerBufferSize: 3
failureRateThreshold: 50
minimumNumberOfCalls: 2
automaticTransitionFromOpenToHalfOpenEnabled: true
waitDurationInOpenState: 5s
permittedNumberOfCallsInHalfOpenState: 3
slidingWindowSize: 10
slidingWindowType: TIME_BASED

The method that invokes the custom config file mentioned above:

@Override
@CircuitBreaker(name = "serviceA", fallbackMethod = "ContactsServiceDown")
public void runCommands(String val) {
    //code logic
}
public void ContactsServiceDown() {

    System.out.println("service down");
}

I have created a test method that calls runCommands and throws an exception whenever it is invoked which executes more than 25 times, but I am not getting a hit in the fallback method. Is there any possible way we can read the values from resilance4J.yml file?

vatbub
  • 2,713
  • 18
  • 41
Vivekann
  • 11
  • 2
  • Please follow [ask], not forgetting about grammar, too – HoRn Jul 19 '22 at 19:46
  • It doesn't seem the yml file is well indented. Moreover, where exactly is the exception launched in your test? – AddeusExMachina Jul 25 '22 at 09:40
  • The fallback method should accept an argument of type Exception. Your fallback method signature should be updated as `public void ContactsServiceDown(String val, Exception e)` – Krithick S Nov 27 '22 at 14:25

0 Answers0