Springs RestTemplate默认连接池 [英] Springs RestTemplate default connection pool

查看:1211
本文介绍了Springs RestTemplate默认连接池的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

只是想知道RestTemplate是否开箱即用使用连接池,还是只是每次都建立一个新的连接?

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

推荐答案

我相信RestTemplate不会使用连接池发送请求,它会使用SimpleClientHttpRequestFactory来包装标准JDK打开和关闭连接.

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.

实际上,您可以将RestTemplate配置为使用池化的实现,例如HttpComponentsClientHttpRequestFactory,但是最有可能的是,您可能还需要配置一些设置以防止请求超时.

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.

我在疑难解答中写了关于此问题的博客. Spring的RestTemplate请求超时

这篇关于Springs RestTemplate默认连接池的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆