Commit 0d971952 by 罗志长

fix: keepalive

parent 1faa04b0
...@@ -2,6 +2,7 @@ package com.makeit.config.es; ...@@ -2,6 +2,7 @@ package com.makeit.config.es;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
...@@ -14,11 +15,9 @@ public class ElasticSearchClientConfig { ...@@ -14,11 +15,9 @@ public class ElasticSearchClientConfig {
@Bean(name = "restHighLevelClient") @Bean(name = "restHighLevelClient")
public RestHighLevelClient restHighLevelClient() { public RestHighLevelClient restHighLevelClient() {
return new RestHighLevelClient( RestClientBuilder builder = RestClient.builder(new HttpHost(es.getHost(), es.getPort(), es.getScheme()))
RestClient.builder( .setHttpClientConfigCallback(httpClientBuilder -> httpClientBuilder.setKeepAliveStrategy((httpResponse, httpContext) -> 1000 * 60));
new HttpHost(es.getHost(), es.getPort(), es.getScheme()) return new RestHighLevelClient(builder);
)
);
} }
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment