spring-cloud-circuitbreaker icon indicating copy to clipboard operation
spring-cloud-circuitbreaker copied to clipboard

Annotation based Spring Cloud Circuit breaker

Open patpatpat123 opened this issue 5 years ago • 9 comments

Is your feature request related to a problem? Please describe. Problem: This project is amazing. However, currently, the application layer have to have code tied with the business logic to perform circuit breaker. The Spring Boot Starter Resilience4J project offers a very interesting set of annotations where methods can be annotated, and the decoration pattern will apply, making the code and understand of overall classes much clearer.

Describe the solution you'd like A possibility to have annotations @CircuitBreaker @Retry @Timeout like Spring Boot Starter Resilience4J project, but for Spring-Cloud-CircuitBreaker. It is a very clean and nice feature

Describe alternatives you've considered Well, right now, it is just a lot of code within the classes.

patpatpat123 avatar Nov 08 '20 23:11 patpatpat123

Could you not just use those annotations directly?

ryanjbaxter avatar Nov 30 '20 22:11 ryanjbaxter

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

spring-projects-issues avatar Dec 07 '20 22:12 spring-projects-issues

Hello @ryanjbaxter,

Just tried for the last couple of days. Updated to the latest SpringBoot 2.4.1 with the latest Ilford M6, and the Spring Cloud Circuit Breaker.

It seems the annotations @timed @count etc... are just from

    <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-micrometer</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-reactor</artifactId>
        </dependency>
        <dependency>
            <groupId>io.github.resilience4j</groupId>
            <artifactId>resilience4j-spring-boot2</artifactId>
        </dependency>

The Spring Cloud Circuit breaker itself does not have the annotations (or am I using the wrong ones?)

And if I combine the jars (have the resilience4j ones and spring cloud circuit breaker, the resilience4j ones works, but yield the same behavior as if only resilience4j jars, with no circuit breaker).

patpatpat123 avatar Dec 14 '20 11:12 patpatpat123

If you are just going to use the Resilience4J annotations why would you include the spring cloud circuitbreaker jars?

ryanjbaxter avatar Dec 14 '20 14:12 ryanjbaxter

That's pretty much the purpose of this request for enhancement 😅

Is it possible to use spring cloud circuit breaker jar, without resilience4j, but still have the annotations?

Currently, if I exclude resilience4j jars, just using spring cloud circuit breaker jars, there are no annotations at all (reason of this enhancement request)

patpatpat123 avatar Dec 14 '20 14:12 patpatpat123

Yeah not currently we dont have annotations. The topic has come up before, I thought there was already an issue open for this but I can't seem to find it, so maybe it was just conversations we have had.

Anyways we were waiting to see if there was enough demand from the community before actually adding any annotations.

ryanjbaxter avatar Dec 14 '20 18:12 ryanjbaxter

many thanks! Hope to see it one day

patpatpat123 avatar Dec 14 '20 18:12 patpatpat123

I would also vote for annottations. Auto-Wiring the CircuitBreakerFactory and the replace the original method with factory.create().run() code is repeating over and over again, especiall when your are coming from @HystrixCommand. If you are going for an annotation, please add the configuration for all the exceptions (ignored) directly into the annotation and not in the application.properties, because this can cause easily refactoring issues (@hystrixCommand did this for ignored exceptions, good job!)

camproto avatar Mar 03 '22 08:03 camproto

This would be definitively a great improvement. I think this would help a lot people who are migrating from hystrix-javanica.

mehdikhelif avatar Aug 05 '22 13:08 mehdikhelif