...
|
...
|
@@ -10,6 +10,7 @@ import org.apache.http.auth.AuthScope; |
|
|
import org.apache.http.auth.UsernamePasswordCredentials;
|
|
|
import org.apache.http.client.CredentialsProvider;
|
|
|
import org.apache.http.impl.client.BasicCredentialsProvider;
|
|
|
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
|
|
|
import org.elasticsearch.client.RestClient;
|
|
|
import org.elasticsearch.client.RestClientBuilder;
|
|
|
import org.elasticsearch.client.RestHighLevelClient;
|
...
|
...
|
@@ -21,6 +22,7 @@ import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfig |
|
|
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.time.Duration;
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -86,6 +88,12 @@ public class ElasticSearchConfig extends AbstractElasticsearchConfiguration { |
|
|
httpAsyncClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
|
|
|
return httpAsyncClientBuilder;
|
|
|
});
|
|
|
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
|
|
|
@Override
|
|
|
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpAsyncClientBuilder) {
|
|
|
return httpAsyncClientBuilder.setKeepAliveStrategy(((httpResponse, httpContext) -> Duration.ofMinutes(5).toMillis()));
|
|
|
}
|
|
|
});
|
|
|
RestHighLevelClient client = new RestHighLevelClient(builder);
|
|
|
return client;
|
|
|
}
|
...
|
...
|
|