What does setDefaultMaxPerRoute and setMaxTotal mean in HttpClient?

后端 未结 1 1573
名媛妹妹
名媛妹妹 2021-02-01 19:16

I am using Apache HttpClient in one of my project. I am also using PoolingHttpClientConnectionManager along with my HttpClient as well.

I am confuse what ar

相关标签:
1条回答
  • 2021-02-01 20:00

    Some parameters are explained at http://hc.apache.org/httpclient-3.x/preference-api.html

    Others must be gleaned from the source.

    • setMaxTotal

    The maximum number of connections allowed across all routes.

    • setDefaultMaxPerRoute

    The maximum number of connections allowed for a route that has not been specified otherwise by a call to setMaxPerRoute. Use setMaxPerRoute when you know the route ahead of time and setDefaultMaxPerRoute when you do not.

    • setConnectTimeout

    How long to wait for a connection to be established with the remote server before throwing a timeout exception.

    • setSocketTimeout

    How long to wait for the server to respond to various calls before throwing a timeout exception. See http://docs.oracle.com/javase/1.5.0/docs/api/java/net/SocketOptions.html#SO_TIMEOUT for details.

    • setConnectionRequestTimeout

    How long to wait when trying to checkout a connection from the connection pool before throwing an exception (the connection pool won't return immediately if, for example, all the connections are checked out).

    • setStaleConnectionCheckEnabled

    Can be disabled for a slight performance improvement at the cost of potential IOExceptions. See http://hc.apache.org/httpclient-3.x/performance.html#Stale_connection_check

    0 讨论(0)
提交回复
热议问题