Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Portal 模块 RestTemplate 支持配置 ConnectionTimeToLive #5121

Merged
merged 1 commit into from
Apr 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.springframework.web.client.RestTemplate;

import java.io.UnsupportedEncodingException;
import java.util.concurrent.TimeUnit;

@Component
public class RestTemplateFactory implements FactoryBean<RestTemplate>, InitializingBean {
Expand Down Expand Up @@ -58,7 +59,9 @@ public boolean isSingleton() {
}

public void afterPropertiesSet() throws UnsupportedEncodingException {
CloseableHttpClient httpClient = HttpClientBuilder.create().build();
CloseableHttpClient httpClient = HttpClientBuilder.create()
.setConnectionTimeToLive(portalConfig.connectionTimeToLive(), TimeUnit.MILLISECONDS)
.build();

restTemplate = new RestTemplate(httpMessageConverters.getConverters());
HttpComponentsClientHttpRequestFactory requestFactory =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ public int readTimeout() {
return getIntProperty("api.readTimeout", 10000);
}

public int connectionTimeToLive() {
return getIntProperty("api.connectionTimeToLive", -1);
}

public List<Organization> organizations() {

String organizations = getValue("organizations");
Expand Down
Loading