Hi,
I was checking the options for Circuit Breaker:
https://resilience4j.readme.io/docs/circuitbreaker
But I didn麓t see the possibility to evaluate a successful response as a failure. This possibility is available for another behaviour Retry:
https://resilience4j.readme.io/docs/retry
result -> false
Configures a Predicate which evaluates if a result should be retried. The Predicate must return true, if the result should be retried, otherwise it must return false.
Do you think that it is possible to add something similar in this behaviour?
Many thanks in advance.
Juan Antonio
The simplest way is to throw an exception from your client (for the successful response you want to mark as failure) and put that exception in record exception list of circuit breaker.
Hi,
no, not yet.
I close this issue, because it's a duplicate of https://github.com/resilience4j/resilience4j/issues/384
Please have a look at the discussion.
We created a SupplierUtils which helps you in situations where you can't modify the client code.
```
Supplier
Supplier
if (result.getStatusCode() == 400) {
throw new HttpClientServerException();
} else if (result.getStatusCode() == 500) {
throw new HttpServerException();
}
return result;
});
HttpResponse httpResponse = circuitBreaker
.executeSupplier(supplierWithResultHandling);
````
Many thanks, I will try this approach
Applied the solution and the usage is easy.