3

JobServiceImpl.java:

@CircuitBreaker(name = "jobsApiServiceGetAllJobs", fallbackMethod = "getAllJobsFallback")
public ResponseEntity<JobsResponse> getAllJobs() {
    ...
    throw new ApiException();
}

public ResponseEntity<JobsResponse> getAllJobsFallback(Throwable throwable) {
    log.error("Fallback method called");
}

application.properties:

resilience4j.circuitbreaker.instances.jobsApiServiceGetAllJobs.ignoreExceptions=ccp.shared.platform.exception.ApiException,ccp.shared.platform.exception.BadRequestApiException

Whenever ccp.shared.platform.exception.ApiException is thrown, the fallback method is called even though I have added it in the ignoreExceptions list in the application.properties file. I want it to not trigger the fallback method when ApiException is thrown. I have tried similar questions on stack overflow and those does not work for me. Am I doing anything wrong?

Arshad Yusuf
  • 519
  • 1
  • 5
  • 11

2 Answers2

4

Seems that the property is defined in the docs but actually, it does not work. There is a pull request for that -> CircuitBreakerConfigurationProperties has no ignoreException property.

You can use the common Spring+java configuration to achieve that in the meantime:

@Bean
CircuitBreaker reportingApiCircuitBreaker(CircuitBreakerRegistry registry) {
    CircuitBreakerConfig config = CircuitBreakerConfig.custom()
        .ignoreExceptions(ApiException.class, BadRequestApiException.class)
        .build();

    return registry.circuitBreaker("yourCircuitBreakername", config);
}
Felipe
  • 7,013
  • 8
  • 44
  • 102
0

Pls try this way

resilience4j.circuitbreaker.instances.jobsApiServiceGetAllJobs.ignoreExceptions[0]=ccp.shared.platform.exception.ApiException
resilience4j.circuitbreaker.instances.jobsApiServiceGetAllJobs.ignoreExceptions[1]=ccp.shared.platform.exception.BadRequestApiException
Alexandr Kovalenko
  • 934
  • 1
  • 12
  • 13