我需要为以下客户端或配置设置自定义超时:
import org.apache.cxf.jaxrs.client.Client;
import org.apache.cxf.jaxrs.client.WebClient;
import org.apache.cxf.jaxrs.client.ClientConfiguration;
Client client = WebClient.client(api);
ClientConfiguration config = WebClient.getConfig(client);
答案 0 :(得分:0)
import org.apache.cxf.transport.http.HTTPConduit;
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
客户端客户端= WebClient.client(api);
HTTPConduit http =(HTTPConduit)client.getConduit();
HTTPClientPolicy httpClientPolicy = new HTTPClientPolicy(); httpClientPolicy.setConnectionTimeout(0);
httpClientPolicy.setReceiveTimeout(0);
http.setClient(httpClientPolicy);
答案 1 :(得分:0)
我需要将其添加到我之前发布的代码中:
HTTPConduit conduit = config.getHttpConduit();
conduit.getClient().setReceiveTimeout(150000);
//conduit.getClient().setConnectionTimeout(120000);
它有效。我只需要设置接收超时,但连接超时设置也可以。