问题
I have to set a different timeout in Apache cxf request based on some condition in my request
my current code looks like this
<http-conf:client ReceiveTimeout="120000" AcceptEncoding="gzip, deflate"/>
Now is there any way to change this receive timeout for a particular request based on some condition.
回答1:
Current we don't provide this kind of setting in CXF. If you still want to do that, you can get the HttpConduit from the CXF client proxy and set the HTTPClientPolicy directly to the HttpConduit.
// Get the HttpConduit
HttpConduit httpConduit = (HttpConduit) ClientProxy.getClient(greeter).getConduit();
// Set your custom HTTPClientPolicy directly to the httpConduit
httpConduit.setHTTPClientPolicy(httpClientPolicy);
In this way, you can update the timeout before sending the request to the server.
来源:https://stackoverflow.com/questions/21979933/changing-client-timeout-for-a-particular-request-in-apache-cxf