Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The recent addition to CXF failover features is the implementation based on circuit breakers, more precisely Apache Zest (https://zest.apache.org/) library. It is available starting from CXF 3.2.0.

The configuration is very similar to the regular failover strategy, the only difference is usage of clustering:circuit-breaker-failover element.

...

Code Block
java
java
org.apache.cxf.jaxrs.features.clustering.CircuitBreakerFailoverFeaturefeatureCircuitBreakerFailoverFeature feature = 
    new org.apache.cxf.jaxrs.features.clustering.CircuitBreakerFailoverFeature(1, 60000);
List<String> alternateAddresses = new ArrayList<String>();
// addresses are alternate addresses provided at start-up
for (String s : address) {
    alternateAddresses.add(s);
}
SequentialStrategy strategy = new SequentialStrategy();
strategy.setAlternateAddresses(alternateAddresses);
feature.setStrategy(strategy);

JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
bean.setAddress("http://localhost:8080/inactive-replica");
List<Feature> features = new ArrayList<Feature>();
features.add(feature);
bean.setFeatures(features);

// create proxy:
bean.create(BookStore.class);
// create web client
bean.createWebClient();

...