当前位置:网站首页>Resttemplate connection pool configuration
Resttemplate connection pool configuration
2022-07-27 07:40:00 【white_ while】
adopt RestTemplateBuilder Generated by RestTemplate
@Bean(name = "template")
RestTemplate template(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder
// Company s, Set connection time , Avoid too many threads being blocked and suspended
.setConnectTimeout(Duration.ofSeconds(1))
.setReadTimeout(Duration.ofSeconds(1))
.additionalMessageConverters(new MyMappingJackson2HttpMessageConverter())
.requestFactory(() -> {
HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = new HttpComponentsClientHttpRequestFactory();
// Connection pool
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
// Set up HTTP Connection manager
PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager();
poolingConnectionManager.setMaxTotal(500); // Maximum number of connections in connection pool
poolingConnectionManager.setDefaultMaxPerRoute(200); // Concurrency per host
httpClientBuilder.setConnectionManager(poolingConnectionManager);
// Set up connection pool
clientHttpRequestFactory.setHttpClient(httpClientBuilder.build());
return clientHttpRequestFactory;
})
.build();
}
restTemplate Connection of by RequestFactory establish
HttpComponentsClientHttpRequestFactory yes RequestFactory Implementation class , Connection pooling , Yes httpClient quote
RestTemplateBuilder Used to generate restTeamplte
configure Method initialized RequestFactory Object passing buildRequestFactory
public ClientHttpRequestFactory buildRequestFactory() {
ClientHttpRequestFactory requestFactory = null;
if (this.requestFactory != null) {
requestFactory = (ClientHttpRequestFactory)this.requestFactory.get();
} else if (this.detectRequestFactory) {
// Default connection pool factory
requestFactory = (new ClientHttpRequestFactorySupplier()).get();
}
if (requestFactory != null && this.requestFactoryCustomizer != null) {
this.requestFactoryCustomizer.accept(requestFactory);
}
return requestFactory;
}
边栏推荐
- Array method and loop in JS
- VLAN trunk experiment
- The first open source MySQL native HTAP database in China will be released soon! Look at the three highlights first, limited to the surrounding areas, waiting for you~
- ClickHouse 笔记1 | 简介、特点 | 基于CentOS7系统的安装与使用 | 常用数据类型 | MergeTree 表引擎 | SQL操作
- Using docker in MAC to build Oracle database server
- Clickhouse notes 1 | introduction, features | installation and use based on centos7 system | common data types | mergetree table engine | SQL operation
- DASCTF2022.07赋能赛密码wp
- ARP广播实践案例
- 次轮Okaleido Tiger即将登录Binance NFT,引发社区热议
- 「翻译」SAP变式物料的采购如何玩转?看看这篇你就明白了
猜你喜欢

mysql备份策略

什么是真正的HTAP?(一)背景篇

ARP broadcasting practice cases

记录一个自己挖的坑~

LeetCode56. 合并区间

C language implementation of guessing numbers Games project practice (based on srand function, rand function, switch statement, while loop, if condition criterion, etc.)

Gossip: Recently, many friends talk about going abroad

opengl-shader学习笔记:varying变量

Apifox安装及使用

C语言实现猜数字小游戏项目实战(基于srand函数、rand函数,Switch语句、while循环、if条件判据等)
随机推荐
Bingbing's learning notes: classes and objects (middle)
【pytorch】ResNet18、ResNet20、ResNet34、ResNet50网络结构与实现
Quickly update the information in a field in kettle
连接MySQL时报错:Public Key Retrieval is not allowed 【解决方法】
小程序消息推送配置 Token校验失败,请检查确认
Help send a recruitment, base all over the country. If you are interested, you can come and have a look
Solution to automatic disconnection of SSH link of Tencent ECS
A small cotton padded jacket with air leakage
Multithreading [preliminary - Part 1]
C language pthread_ cleanup_ Push() and pthread_ cleanup_ Pop() function (used for the resource cleaning task after the termination action in the critical resource program segment to avoid deadlock. T
Okaleido生态核心权益OKA,尽在聚变Mining模式
Perl: split the external command to be executed into multiple lines
IDEA中文乱码怎么办
Am I delayed by the code... Unfortunately, I became a programmer
Haikang H9 camera cannot be connected with xshell (SSH is not enabled)
Properties类和properties配置文件的理解学习
基于Arduino的温度、湿度测量显示装置
Chapter 6 Shell Logic and Arithmetic
The first open source MySQL native HTAP database in China will be released soon! Look at the three highlights first, limited to the surrounding areas, waiting for you~
安装tensorflow