Springs RestTemplate default connection pool

前端 未结 4 1638
轮回少年
轮回少年 2020-12-24 13:12

Just wondering if RestTemplate out of the box uses connection pooling or does it simply establish a new connection each time ?

4条回答
  •  孤城傲影
    2020-12-24 13:50

    I believe RestTemplate doesn’t use a connection pool to send requests, it uses a SimpleClientHttpRequestFactory that wraps a standard JDK’s HttpURLConnection opening and closing the connection.

    Indeed you can configure RestTemplate to use a pooled implementation such as HttpComponentsClientHttpRequestFactory but most-likely you might also need to configure some settings to prevent requests from timing out.

    I have blogged about this issue at Troubleshooting Spring's RestTemplate Requests Timeout

提交回复
热议问题