Skip to content

Commit

Permalink
Merge branch 'apolloconfig:master' into gsFeat
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxianhjy authored Aug 26, 2024
2 parents 6ffa845 + f4a0236 commit 4c4aa2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Apollo 2.4.0

------------------
* [Update the server config link in system info page](https://github.com/apolloconfig/apollo/pull/5204)
* [Feature support portal restTemplate Client connection pool config](https://github.com/apolloconfig/apollo/pull/5200)


------------------
All issues and pull requests are [here](https://github.com/apolloconfig/apollo/milestone/15?closed=1)
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.ctrip.framework.apollo.portal.component.config.PortalConfig;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
Expand Down Expand Up @@ -59,8 +60,14 @@ public boolean isSingleton() {
}

public void afterPropertiesSet() throws UnsupportedEncodingException {

PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager();
connectionManager.setMaxTotal(portalConfig.connectPoolMaxTotal());
connectionManager.setDefaultMaxPerRoute(portalConfig.connectPoolMaxPerRoute());

CloseableHttpClient httpClient = HttpClientBuilder.create()
.setConnectionTimeToLive(portalConfig.connectionTimeToLive(), TimeUnit.MILLISECONDS)
.setConnectionManager(connectionManager)
.build();

restTemplate = new RestTemplate(httpMessageConverters.getConverters());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,14 @@ public int connectionTimeToLive() {
return getIntProperty("api.connectionTimeToLive", -1);
}

public int connectPoolMaxTotal() {
return getIntProperty("api.pool.max.total", 20);
}

public int connectPoolMaxPerRoute() {
return getIntProperty("api.pool.max.per.route", 2);
}

public List<Organization> organizations() {

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

0 comments on commit 4c4aa2f

Please sign in to comment.