We are using Camel 2.14, in a spring application, and are utilizing the Camel CXF-RS component (http://camel.apache.org/cxfrs.html) to produce RESTful requests on a 3rd party service.
When their server is off-line and Camel cannot get a connection, it does not time out for 30 seconds. We'd like to be able to tweak this timeout value, but are struggling to see how we can do this. Could anyone advise?
We can see that Camel itself uses values got from HTTPClientPolicy object, which has a setConnectionTimeOut on it.. but how do we get this object?
Can we get the HTTPClientPolicy object programmatically? or must we refer to it in the Camel URI passed to template.send() eg:
template.send("cxfrs://" + url + "/match/" + appId + "/" + reqId?httpClientAPI=true&http.connection.timeout=5000
The link posted before by raphaëλ is correct if you want to configure the endpoint timeouts with XML files. But if you want to do it fully programmatically, you can do it with one of cxf component's option (cxfEndpointConfigurer) as shown in this camel-cxf component unit-test.
In your case it would be something like this:
template.send("cxfrs://" + url + "/match/" + appId + "/" + "reqId?httpClientAPI=true&cxfEndpointConfigurer=#endpointConfigurer"
Then you would need an "endpointConfigurer" bean with a configuration like this:
@Component("endpointConfigurer")
public class TemplateEndpointConfigurer implements CxfEndpointConfigurer {
@Override
public void configure(AbstractWSDLBasedEndpointFactory factoryBean) {
// Do nothing here
}
@Override
public void configureClient(Client client) {
final HTTPConduit conduit = (HTTPConduit) client.getConduit();
final HTTPClientPolicy policy = new HTTPClientPolicy();
policy.setConnectionTimeout(webServiceConnectionTimeout);
policy.setReceiveTimeout(webServiceReadTimeout);
policy.setConnection(ConnectionType.CLOSE);
conduit.setClient(policy);
}
@Override
public void configureServer(Server server) {
// Do nothing here
}
}
Even though this answer comes a bit late, I hope it can help you with your projects.