Resilience4j: CircuitBreaker annotation does not work on methods

Created on 15 Dec 2019  路  6Comments  路  Source: resilience4j/resilience4j

Resilience4j version: 1.2.0
Java version: 1.8
Problem description: CircuitBreaker annotation is working when applied on methods. It works perfected when applied on class.

I am using spring-boot 2.0.2
Using resilence4j dependency: resilience4j-spring-boot2:1.2.0

I found this was working with spring-boot 1.5 and resilience4j-spring-boot:0.17.0

Example:
the below one works

@Component(value = "backendAConnector")
@CircuitBreaker(name = "backendA")
public class BackendAConnector {

    public String success() {
        return "Hello World from backend A";
    }
}

the below one doesn't work

@Component(value = "backendAConnector")
public class BackendAConnector {

    @CircuitBreaker(name = "backendA")
    public String success() {
        return "Hello World from backend A";
    }
}

Most helpful comment

Sorry for the delayed response.
I was calling the method incorrectly. Since resilience4j annotation are AOP based. I was calling the methods from within the BackendAConnector class.
It started working when I called the function from different class and using the object as bean.

All 6 comments

Found the issue why is was not working. Closing this.

It would nice to consider sharing your corrections if something is missed in the documentation it will be added.

@warrior107 Hey, can you share your solution here? I am facing similar problem.

@warrior107 Hey, can you share your solution here? I am facing similar problem.

For anyone ending up here and to try making the internet a better place.

Try to check your configuration and see if you have:

management.health.circuitbreakers.enabled = true

Sorry for the delayed response.
I was calling the method incorrectly. Since resilience4j annotation are AOP based. I was calling the methods from within the BackendAConnector class.
It started working when I called the function from different class and using the object as bean.

@warrior107 I was able to fix the problem, was doing the same mistake, calling function incorrectly.
Thanks anyways.

Was this page helpful?
0 / 5 - 0 ratings