As per the documentation -
https://cwiki.apache.org/confluence/display/CXF20DOC/JAX-RS+Failover#JAX-RSFailover-Code.1,
I tried running the following code along with associated configurations, but
the circuit breaker mechanism is not opening up once the threshold count for
connectivity failures have exceeded. As the circuit stays closed, the
invocation attempts are still being accepted which is against expected
behaviour.
public class CustomerRestClient {    private CustomerRestClientFactory
customerRestClientFactory;    public List filterByFirstName(String
firstName) {        List filteredCustomers = new ArrayList<>();       
CircuitBreakerFailoverFeature cbFailoverFeature = new
CircuitBreakerFailoverFeature(4, 180000L);        SequentialStrategy
strategy = new SequentialStrategy();       
cbFailoverFeature.setStrategy(strategy);                List featureList =
new ArrayList();        featureList.add(cbFailoverFeature);        WebClient
client = customerRestClientFactory.getClient(featureList).path("/");       
// Call service to get all customers        List customers = client.get(new
GenericType<List&lt;Customer>>() {});        return filteredCustomers;    }   
public void setCustomerRestClientFactory(CustomerRestClientFactory
customerRestClientFactory) {        this.customerRestClientFactory =
customerRestClientFactory;    }}public class CustomerRestClientFactory
implements InitializingBean {    private List providerList;  // Value is
injected by Spring    private String serviceUrl;  // Value is injected by
Spring    public WebClient getClient(List<? extends Feature> featureList) {     
  
if (featureList == null || featureList.isEmpty()) {            throw new
IllegalArgumentException("featureList is not initialized.");        }       
JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();       
bean.setAddress(serviceUrl);        bean.setServiceClass(WebClient.class);      
 
bean.setProviders(providerList);        bean.setFeatures(featureList);       
return bean.createWebClient();    }}                                 
NON_NULL                      
 Log containing stack traces (attached).After a lot of debugging, I came to
an understanding that the counter for connection failures never exceeds the
threshold limit because the state of the data (including the counter) is
specific to each of the WebClient objects, instantiated for each call. I
assumed that if the same instance of a WebClient is used across multiple
calls that fail, then the counter would have been updated and eventually
open the circuit. Please find attached screenshot for details 
<http://cxf.547215.n5.nabble.com/file/t341168/Reason_UnableToOpenCircuit_WebClient_ProgramaticApproach.png>
 
app.log <http://cxf.547215.n5.nabble.com/file/t341168/app.log>  .1) Is my
understanding correct?2) Kindly help with a working example, as the one
mentioned in CWIKI documentation is not working.



--
Sent from: http://cxf.547215.n5.nabble.com/cxf-user-f547216.html

Reply via email to