Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to keep different CircuitBreakerConfiguration for multiple circuit breakers? #62

Open
hmantri05 opened this issue Apr 21, 2022 · 8 comments

Comments

@hmantri05
Copy link

I have created a @bean of CircuitBreakerRegistry and have annotated four different methods using @CIRCUITBREAKER annotation. All have different names.

Screenshot 2022-04-21 at 9 35 44 AM

Screenshot 2022-04-21 at 9 36 32 AM

I want to keep 4 different kinds of CircuitBreakerConfig in the registry for each of the circuit breaker.

How can I achieve this?

Also, I want to log every event on these four CircuitBreakers. I know we can achieve that using:
registry.circuitBreaker(name).getEventPublisher().onEvent(logger)

But how do I get hold of the reference to those four circuit breakers?

@RobWin

@RobWin
Copy link
Member

RobWin commented Apr 21, 2022

Hi why don't you use the Spring Boot starter and external configuration?
Did you have a look at the demo?

@RobWin
Copy link
Member

RobWin commented Apr 21, 2022

See link for event consumer registration.

public RegistryEventConsumer<CircuitBreaker> myRegistryEventConsumer() {

@hmantri05
Copy link
Author

@RobWin So we have an internal tool (CCM) where we keep the configs and which can be changed at runtime as well. The hardcoded values that I have shown in the above screenshot, I am going to feed those values from our CCM config classes. So I can't use the application.properties config here.

@RobWin
Copy link
Member

RobWin commented Apr 21, 2022

Cannot you make use of Spring Cloud Config instead? It allows the reconfiguration at runtime.
Otherwise how do you trigger a reconfiguration in Spring Boot?

@hmantri05
Copy link
Author

@RobWin So the application keeps on polling the CCM to see if there are any changes every minute. It's a company wide used tool. Inhouse built.

@RobWin
Copy link
Member

RobWin commented Apr 21, 2022

But how do you refresh the Registry? Do you replace the CircuitBreaker instances?

@hmantri05
Copy link
Author

@RobWin The current use case is to have four diffent configs with which we can initialize the circuit breakers. For now there is no need to refresh the config at runtime.
But that's a valid point. May be you can suggest something around refreshing the circuit breakers live as well. :D

@RobWin
Copy link
Member

RobWin commented Apr 22, 2022

I would propose to use Spring Cloud Config and build an adapter around your internal CCM tool.
Use the external config file to configure your 4 CircuitBreakers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants