I had tried some heavy exploration on enabling Failover feature, as per
documentation provided by Apache CXF. While the one for SOAP client works
like a charm, the other one for REST client is not so with the way I am
trying to instantiate the client. My requirement of instantiating the REST
client is via JAXRS 2.0.1 API, as shown in following sample code.NOTE : The
following endpoint URL is a valid one, except that the port number has been
switched from 8080 (working one) to 8081 (non-working one), since I need to
simulate the invocation failure retry behavior.Client client =
ClientBuilder.newClient(); WebTarget target =
client.target("http://localhost:8081/my-app/ws/ers/customers";);
Invocation.Builder builder =
target.request(MediaType.APPLICATION_JSON_TYPE); Response response =
builder.get();I have found that the Failover feature is not working when the
above last line of code is invoked.Now, here comes the interesting part. I
have found only 2 classes in cxf-rt-rs-client-3.1.0-sources.jar where the
initialization of Failover feature in a
org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean instance happens. And my
requirement is to have one of these methods (or, a similar one where
bean.setFeatures(features) is invoked ) being called.Method in
org.apache.cxf.jaxrs.client.JAXRSClientFactory class.public static  T
create(String baseAddress,                        Class cls, List<?>
providers,                       List features,                                 
         
String configLocation) {    JAXRSClientFactoryBean bean =
getBean(baseAddress, cls, configLocation);    bean.setProviders(providers);   
bean.setFeatures(features);    return bean.create(cls);}Method in
org.apache.cxf.jaxrs.client.WebClient class.public static WebClient
create(String baseAddress,                            List<?> providers,        
                   
List<? extends Feature> features,                           String
configLocation) {    JAXRSClientFactoryBean bean = getBean(baseAddress,
configLocation);    bean.setProviders(providers);   
bean.setFeatures(features);    return bean.createWebClient();}However, when
my custom client code above is executed, neither of the above 2 methods have
been invoked. Instead, the following method in
org.apache.cxf.jaxrs.client.spec.ClientImpl is invoked.private void
initTargetClientIfNeeded() {    URI uri = this.uriBuilder.build(new
Object[0]);    if(this.targetClient == null) {        JAXRSClientFactoryBean
bean = new JAXRSClientFactoryBean();        bean.setAddress(uri.toString());    
   
this.targetClient = bean.createWebClient();       
ClientImpl.this.baseClients.add(this.targetClient);    }     else
if(!this.targetClient.getCurrentURI().equals(uri)) {       
this.targetClient.to(uri.toString(), false);    } }Does this imply that
Failover Feature is NOT supported for CXF version 3.1.0 ?If so, which
upcoming version of CXF will support my above requirement ?



--
View this message in context: 
http://cxf.547215.n5.nabble.com/No-support-for-FailoverFeature-in-CXF-Rest-Client-implementation-version-3-1-0-tp5765813.html
Sent from the cxf-user mailing list archive at Nabble.com.

Reply via email to