JasionL
JasionL
2017-10-10 09:22

httpclient怎么设置连接池连接等待时间

  • java
  • httpclient
连接满时,会处于连接池等待状态,怎么设置连接池等待时间,避免造成长时间等待
求大神解答,急!在线等!!!!

/*读取超时*/
private final static int SOCKET_TIMEOUT = 50000;
/*连接超时*/
private final static int CONNECTION_TIMEOUT = 50000;
/*每个HOST的最大连接数量*/
private final static int MAX_CONN_PRE_HOST = 2;
/*连接池的最大连接数*/
private final static int MAX_CONN = 60;
/*连接池*/
private final static HttpConnectionManager httpConnectionManager;

static{     
    httpConnectionManager = new MultiThreadedHttpConnectionManager();
    HttpConnectionManagerParams params = httpConnectionManager.getParams();
    params.setConnectionTimeout(CONNECTION_TIMEOUT);
    params.setSoTimeout(SOCKET_TIMEOUT);
    params.setDefaultMaxConnectionsPerHost(MAX_CONN_PRE_HOST);
    params.setMaxTotalConnections(MAX_CONN);

}
  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答

为你推荐