[ 
https://issues.apache.org/jira/browse/CAMEL-15928?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Alex Liroyd updated CAMEL-15928:
--------------------------------
    Description: 
Currently Timeout exceptions does not trigger circuit breaker. But they should. 
I don't want to continue spam my server, if it slightly started dying.

I tried to hot-fix in the next way - [^hot_fix.diff]

The idea behind patch is next. Currently we wrap our call with circuit breaker 
and only after that with time limiter. So, circuit breaker doesn't know 
anything about time-outs. 

And basically I do opposite - initially wrap call with time limiter and only 
after that, wrap it with circuit breaker. So circuit breaker will aware about 
time-out exception and can react properly.

The issue which I have afterward, that, for cases when circuit breaker was 
open, I started receiving blank 200 OK response.

I tried to fix it by removing recover(fallbackTask) part at all:

 
{code:java}
// Try.ofCallable(task).recover(fallbackTask).andFinally(() -> 
callback.done(false)).get(); //old code
Try.ofCallable(task).andFinally(() -> callback.done(false)).get(); // new line 
of code
{code}
And seems like it works fine. But tests are failing, and I'm not sure how 
exactly it should be fixed. 

Also another fix, which seems like works fine and tests are not failing:

CircuitBreakerFallbackTask

 
{code:java}
} else if (throwable instanceof CallNotPermittedException) {
    // the circuit breaker triggered a call rejected
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_SUCCESSFUL_EXECUTION, 
false);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_FROM_FALLBACK, false);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_SHORT_CIRCUITED, 
true);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_REJECTED, true);
    throw RuntimeExchangeException.wrapRuntimeException(throwable); // new line 
of code
    //return exchange; // old code
{code}
 

 

Please, assist.

  was:
Currently Timeout exceptions does not trigger circuit breaker. But they should. 
I don't want to continue spam my server, if it slightly started dying.

I tried to hot-fix in the next way - [^hot_fix.diff]

The idea behind patch is next. Currently we wrap our call with circuit breaker 
and only after that with time limiter. So, circuit breaker doesn't know 
anything about time-outs. 

And basically I do opposite - initially wrap call with time limiter and only 
after that, wrap it with circuit breaker. So circuit breaker will aware about 
time-out exception and can react properly.

The issue which I have afterward, that, for cases when circuit breaker was 
open, I started receiving blank 200 OK response.

I tried to fix it by removing recover(fallbackTask) part at all:

 
{code:java}
Try.ofCallable(task).recover(fallbackTask).andFinally(() -> 
callback.done(false)).get();
{code}
And seems like it works fine. But tests are failing, and I'm not sure how 
exactly it should be fixed. 

Also another fix, which seems like works fine and tests are not failing:

CircuitBreakerFallbackTask

 
{code:java}
} else if (throwable instanceof CallNotPermittedException) {
    // the circuit breaker triggered a call rejected
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_SUCCESSFUL_EXECUTION, 
false);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_FROM_FALLBACK, false);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_SHORT_CIRCUITED, 
true);
    exchange.setProperty(CircuitBreakerConstants.RESPONSE_REJECTED, true);
    throw RuntimeExchangeException.wrapRuntimeException(throwable); // new line 
of code
    //return exchange; // old code
{code}
 

 

Please, assist.


> TimeoutException does not trigger Resilience4j circuit breaker
> --------------------------------------------------------------
>
>                 Key: CAMEL-15928
>                 URL: https://issues.apache.org/jira/browse/CAMEL-15928
>             Project: Camel
>          Issue Type: Bug
>          Components: came-core, camel-core-engine, eip
>    Affects Versions: 3.4.4
>            Reporter: Alex Liroyd
>            Priority: Critical
>         Attachments: hot_fix.diff
>
>
> Currently Timeout exceptions does not trigger circuit breaker. But they 
> should. I don't want to continue spam my server, if it slightly started dying.
> I tried to hot-fix in the next way - [^hot_fix.diff]
> The idea behind patch is next. Currently we wrap our call with circuit 
> breaker and only after that with time limiter. So, circuit breaker doesn't 
> know anything about time-outs. 
> And basically I do opposite - initially wrap call with time limiter and only 
> after that, wrap it with circuit breaker. So circuit breaker will aware about 
> time-out exception and can react properly.
> The issue which I have afterward, that, for cases when circuit breaker was 
> open, I started receiving blank 200 OK response.
> I tried to fix it by removing recover(fallbackTask) part at all:
>  
> {code:java}
> // Try.ofCallable(task).recover(fallbackTask).andFinally(() -> 
> callback.done(false)).get(); //old code
> Try.ofCallable(task).andFinally(() -> callback.done(false)).get(); // new 
> line of code
> {code}
> And seems like it works fine. But tests are failing, and I'm not sure how 
> exactly it should be fixed. 
> Also another fix, which seems like works fine and tests are not failing:
> CircuitBreakerFallbackTask
>  
> {code:java}
> } else if (throwable instanceof CallNotPermittedException) {
>     // the circuit breaker triggered a call rejected
>     
> exchange.setProperty(CircuitBreakerConstants.RESPONSE_SUCCESSFUL_EXECUTION, 
> false);
>     exchange.setProperty(CircuitBreakerConstants.RESPONSE_FROM_FALLBACK, 
> false);
>     exchange.setProperty(CircuitBreakerConstants.RESPONSE_SHORT_CIRCUITED, 
> true);
>     exchange.setProperty(CircuitBreakerConstants.RESPONSE_REJECTED, true);
>     throw RuntimeExchangeException.wrapRuntimeException(throwable); // new 
> line of code
>     //return exchange; // old code
> {code}
>  
>  
> Please, assist.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to