Skip to content

Commit

Permalink
[INLONG-1798]RestTemplate does not read configuration from the config…
Browse files Browse the repository at this point in the history
…uration file (#1799)

Co-authored-by: zhoupeng <“zhouyaobin1612@163.com”>
  • Loading branch information
ciscozhou and zhoupeng committed Nov 16, 2021
1 parent 5f0b526 commit 03caafe
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.apache.http.protocol.HttpContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
Expand All @@ -51,27 +52,33 @@ public class RestTemplateConfig {
/**
* Max total
*/
private int maxTotal = 5000;
@Value("${common.http-client.maxTotal}")
private int maxTotal;
/**
* Concurrency
*/
private int defaultMaxPerRoute = 2000;
@Value("${common.http-client.defaultMaxPerRoute}")
private int defaultMaxPerRoute;

private int validateAfterInactivity = 5000;
@Value("${common.http-client.validateAfterInactivity}")
private int validateAfterInactivity;

/**
* Time to connect to the server (successful handshake), timeout throws connect timeout
*/
private int connectionTimeout = 3000;
@Value("${common.http-client.connectionTimeout}")
private int connectionTimeout;
/**
* The time for the server to return data (response), timeout throws read timeout
*/
private int readTimeout = 10000;
@Value("${common.http-client.readTimeout}")
private int readTimeout;
/**
* Get the timeout time of the connection from the connection pool,
* and throw ConnectionPoolTimeoutException when timeout
*/
private int connectionRequestTimeout = 3000;
@Value("${common.http-client.connectionRequestTimeout}")
private int connectionRequestTimeout;

@Bean
public PoolingHttpClientConnectionManager httpClientConnectionManager() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ cluster.zk.root=inlong_hive
sort.appName=inlong_app

# Configure http client
common.http-client.maxTotal=5001
common.http-client.defaultMaxPerRoute=2001
common.http-client.validateAfterInactivity=5001
common.http-client.connectionTimeout=3001
common.http-client.readTimeout=10001
common.http-client.connectionRequestTimeout=3001
#common.http-client.maxTotal=5001
#common.http-client.defaultMaxPerRoute=2001
#common.http-client.validateAfterInactivity=5001
#common.http-client.connectionTimeout=3001
#common.http-client.readTimeout=10001
#common.http-client.connectionRequestTimeout=3001

0 comments on commit 03caafe

Please sign in to comment.