Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
K
kwell-mes
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gavelinfo
kwell-mes
Commits
4e05af28
Commit
4e05af28
authored
Apr 01, 2022
by
zhoumaotao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码调整2
parent
c79430c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
0 deletions
+39
-0
RestTemplateConfig.java
.../main/java/com/gavel/kwell/config/RestTemplateConfig.java
+39
-0
No files found.
gavel/src/main/java/com/gavel/kwell/config/RestTemplateConfig.java
0 → 100644
View file @
4e05af28
package
com
.
gavel
.
kwell
.
config
;
import
org.apache.http.conn.HttpClientConnectionManager
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.apache.http.impl.conn.PoolingHttpClientConnectionManager
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.web.client.RestTemplate
;
@Configuration
public
class
RestTemplateConfig
{
@Bean
public
HttpClientConnectionManager
poolingConnectionManager
()
{
PoolingHttpClientConnectionManager
poolingConnectionManager
=
new
PoolingHttpClientConnectionManager
();
poolingConnectionManager
.
setMaxTotal
(
1000
);
// 连接池最大连接数
poolingConnectionManager
.
setDefaultMaxPerRoute
(
500
);
// 每个主机的并发
return
poolingConnectionManager
;
}
@Bean
public
HttpClientBuilder
httpClientBuilder
()
{
HttpClientBuilder
httpClientBuilder
=
HttpClientBuilder
.
create
();
//设置HTTP连接管理器
httpClientBuilder
.
setConnectionManager
(
poolingConnectionManager
());
return
httpClientBuilder
;
}
@Bean
(
"restTemplate"
)
public
RestTemplate
restTemplate
(){
HttpComponentsClientHttpRequestFactory
httpRequestFactory
=
new
HttpComponentsClientHttpRequestFactory
();
httpRequestFactory
.
setHttpClient
(
httpClientBuilder
().
build
());
httpRequestFactory
.
setConnectionRequestTimeout
(
3000
);
//获取链接超时时间
httpRequestFactory
.
setConnectTimeout
(
3000
);
//指客户端和服务器建立连接的timeout
httpRequestFactory
.
setReadTimeout
(
120000
);
//读取数据的超时时间
RestTemplate
restTemplate
=
new
RestTemplate
(
httpRequestFactory
);
return
restTemplate
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment