HttpComponentsClientHttpRequestFactory

If you are using Spring MVC's RestTemplate to make REST calls, it is important to realize that it doesn't use HTTP connection pooling of any kind, and will establish and close a connection every time you make a REST call.

If you want to use connection pooling, you would need to provide another implementation of ClientHttpRequestFactory. A good option is to use the org.springframework.http.client.HttpComponentsClientHttpRequestFactory() which is provided with Spring.

new org.springframework.web.client.RestTemplate(new HttpComponentsClientHttpRequestFactory())
Of course, if you look up the documentation for HttpComponentsClientHttpRequestFactory, you can configure a lot of the connection pooling parameters.

https://coderwall.com/p/dcohra/connection-pooling-with-spring-resttemplate

http://stackoverflow.com/questions/25698072/simpleclienthttprequestfactory-vs-httpcomponentsclienthttprequestfactory-for-htt

org.springframework.http.client.SimpleClientHttpRequestFactory

java.net.Proxy

java.net.Proxy.Type

java.net.InetSocketAddress

org.springframework.web.client.RestTemplate

@Bean
public RestTemplate restTemplate() {
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory(); Proxy proxy= new Proxy(Type.HTTP, new InetSocketAddress("my.host.com", 8080));
requestFactory.setProxy(proxy); return new RestTemplate(requestFactory);
}

put these lines before calling your get or post method. so proxy get set .

    HttpComponentsClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory();
DefaultHttpClient httpClient = (DefaultHttpClient) requestFactory.getHttpClient();
HttpHost proxy = new HttpHost("proxtserver", port);
httpClient.getParams().setParameter(ConnRoutePNames.DEFAULT_PROXY,proxy);
restTemplate.setRequestFactory(requestFactory);

http://stackoverflow.com/questions/3687670/using-resttemplate-how-to-send-the-request-to-a-proxy-first-so-i-can-use-my-jun 

最新文章

  1. JVM内存模型和启动参数的关系
  2. [No000038]操作系统Operating Systems -CPU
  3. Android开发遇到的坑(1):Java中List的安全删除问题
  4. Backbone之旅——Collection and View篇
  5. Ext入门学习系列(五)表格控件(3)
  6. LIBRARY_PATH和LD_LIBRARY_PATH环境变量的区别
  7. de4dot命令 v2.0.3.3405
  8. qt学习:信号,槽
  9. 【笔记】《通俗详细地讲解什么是P和NP问题》的概念记录
  10. Unity3D在一建筑GL材料可以改变颜色和显示样本
  11. dva-quickstart 与 create-react-app 比较(一)
  12. get请求URL的转码
  13. Maven常识
  14. Spring MVC(三)控制器获取页面请求参数以及将控制器数据传递给页面和实现重定向的方式
  15. day_12函数默认值,数据类型的补充,函数对象名称空间与作用域,函数的嵌套定义
  16. centos7如何查找文件?
  17. FortiGate下视频会议等语音相关配置
  18. 【文文殿下】[CEOI2004]锯木厂选址 题解
  19. 异常空格,ASCII (194,160)问题
  20. 多页面应用_vue

热门文章

  1. PHP $_SERVER 详解
  2. pdfkit安装使用
  3. MongoDB性能监控
  4. page show
  5. SQL控制语句中内置函数讲解
  6. 错误记录--The import XXX cannot be resolved
  7. SQL Server 触发器【转】
  8. Mac OS X 上启动 FTP/SFTP server,并设置 log level
  9. zabbix basic concept
  10. php--求几个数中的最小值