changing client timeout for a particular request in Apache CXF

喜欢而已 提交于 2019-12-12 12:26:12

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!