question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

circuit breaker can be called without affecting the state.

See original GitHub issue

Resilience4j version: 1.3.1

Java version: 1.8

I just want to know the circuit breakers status. ex) is open or half-open and can call backend). so I used tryAcquirePermission(). but I missed the comment below.

     * Important: Make sure to call onSuccess or onError after the call is finished.
     * If the call is canceled before it is invoked, you have to release the permission again.

so everything is looks fine until the circuit breaker is half-open. when circuit breaker is half-open, to call tryAcquirePermission is effect permittedNumberOfCallsInHalfOpenState. ( Using this method affects this property.) if call count reached permittedNumberOfCallsInHalfOpenState, circuit breaker stuck half-open

I think need to make a method to check to call permitted a backend service. If possible, I want to make it.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
RobWincommented, Feb 11, 2020

You can create a method like this:

private <T> Mono<T> executeWithFallback(Mono<T> publisher, Function<Throwable, Mono<T>> fallback){
        return publisher
                .transform(TimeLimiterOperator.of(timeLimiter))
                .transform(CircuitBreakerOperator.of(circuitBreaker))
                .onErrorResume(TimeoutException.class, fallback)
                .onErrorResume(CallNotPermittedException.class, fallback);
    }

The fallback can be your message to the user.

Mono<T> result = executeWithFallback(() -> yourService.method(), () ->  Mono.empty());
1reaction
RobWincommented, Feb 11, 2020

This is not how you should use the CircuitBreaker. The exception from the CircuitBreaker tells you that it is open, just map the exception to a proper response to the user. Please don’t do it that way. There is usually no need to use this CircuitBreakerUtil class.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Circuit Breakers and Microservices Architecture
When the circuit breaker is in the CLOSED state, all calls go through to the Supplier Microservice, which responds without any latency.
Read more >
CircuitBreaker - resilience4j
The state of the CircuitBreaker changes from CLOSED to OPEN when the failure rate is equal or greater than a configurable threshold. For...
Read more >
What is Circuit Breaker in Microservices? | by Dineshchandgr
Open — The circuit breaker returns an error for calls without executing the function. Half-Open — After the configured timeout period is reached,...
Read more >
Polly circuitbreaker is not being called - Stack Overflow
The final line outputting circuit state demonstrates the circuit-breaker was affected by (so did take part in) the call.
Read more >
Circuit breaker - Wikipedia
A circuit breaker is an electrical safety device designed to protect an electrical circuit from damage caused by an overcurrent or short circuit....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found