Lazy_bin
Lazy_bin

Reputation: 1

how to get hystrix circuit state?

I'm developing a Spring Boot application with Hystrix for a circuit breaker.

In my application, one business flow consists of several network call to different microservices (e.g. get some data from service A, then based on the response, call service B and C, and based on the response from B and C, call service D).

I need to block the entire flow if any of the services are down.

Does anyone know when a circuit is open or closed or half-open?

Upvotes: 0

Views: 511

Answers (1)

Martin Devillers
Martin Devillers

Reputation: 18002

It feels a bit hacky, but there are some static methods that can get you access to Hystrix's wrapped commands, which in turn gives you access to circuit-status:

HystrixCircuitBreaker myCircuitBreaker = HystrixCircuitBreaker.Factory.getInstance(HystrixCommandKey.Factory.asKey("my command name"))
if(myCircuitBreaker.isOpen()) {
   ...proceed
}

Upvotes: 2

Related Questions