问题
I am trying to configure the CXF Bus, with common timeouts for all clients. For that, I am using HttpConduitFeature and adding it to the Bus during the initial configuration as below:
@Configuration
public class CxfContext {
@Autowired
private SoapConfigurations soapConfigurations;
@Bean
public Bus bus() {
SpringBus b = new SpringBus();
List<Feature> features = ImmutableList.<Feature> builder() //
.add(loggingFeature()) //
.add(conduitFeature()) //
.build();
b.setFeatures(features);
return b;
}
private LoggingFeature loggingFeature() {
LoggingFeature f = new LoggingFeature();
f.setPrettyLogging(true);
f.setVerbose(true);
f.setLimit(-1);
return f;
}
private HttpConduitFeature conduitFeature() {
HttpConduitFeature feature = new HttpConduitFeature();
HttpConduitConfig conduitConfig = new HttpConduitConfig();
HTTPClientPolicy clientPolicy = new HTTPClientPolicy();
clientPolicy.setConnectionTimeout(10000);
clientPolicy.setReceiveTimeout(10000);
conduitConfig.setClientPolicy(clientPolicy);
feature.setConduitConfig(conduitConfig);
return feature;
}
}
After, when generating the Soap client, I am using JaxWsProxyFactoryBean and setting the Bus to it:
@Configuration
public class SoapClientContext {
@Autowired
private Bus bus;
@Bean
public IService myService(SoapConfigurations soapConfigurations) {
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(soapConfigurations.getUrl());
factory.setBus(bus);
return factory.create(IService.class);
}
}
The client is using correctly the logging feature configured in the Bus, but the HttpConduitFeature is not being taken into account. So the timeout is the one by default of 1 minute, instead of the configured 10 seconds.
The only solution I see right now, is setting the HttpConduitFeature directly in the factory:
JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
factory.setAddress(soapConfigurations.getUrl());
factory.setBus(bus);
factory.getFeatures().add(conduitFeature());
Do I need some additional configuration, so the generated clients use the HttpConduitFeature defined in the Bus directly?
来源:https://stackoverflow.com/questions/52873898/cxf-bus-add-httpconduitfeature-with-custom-timeouts