-
Notifications
You must be signed in to change notification settings - Fork 40.6k
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
Spring Boot 3.1 cannot use Elasticsearch Client 8.9.0 #36669
Comments
We'll be upgrading to Elasticsearch Java Client 8.9.0 in Spring Boot 3.2 and depending on the fix it might be possible to backport something (perhaps using reflection to invoke the method). @fabian-froehlich Is there any reason that you need to upgrade the client to 8.9.0? Is staying on the managed 8.7.x version an option for you? |
It looks like |
@philwebb |
Could you provide further assistance? @Bean
@Primary
public RestClientTransport restClientTransport(RestClient restClient, JsonpMapper jsonMapper,
ObjectProvider<RestClientOptions> restClientOptions) {
return new RestClientTransport(restClient, jsonMapper, restClientOptions.getIfAvailable());
} which results in
There are a few definitions of implementations of this interface in |
The auto-configuration of a In the meantime, this should work: @Bean
RestClientTransport restClientTransport(RestClient restClient, ObjectProvider<RestClientOptions> restClientOptions) {
return new RestClientTransport(restClient, new JacksonJsonpMapper(), restClientOptions.getIfAvailable());
} Note that you don't need |
Thanks for your help. I highly appreciate that! With that code the application starts again. I just saw, that we already defined a @Bean
public ElasticsearchClient client(RestClientTransport transport) {
return new ElasticsearchClient(transport);
}
@Bean
public RestClientTransport restClientTransport(
RestClientBuilder restClientBuilder,
ObjectMapper mapper,
SuchdienstProperties properties,
@Qualifier("increasedBuffer") RequestOptions requestOptions
) {
ObjectMapper elasticMapper = mapper.copy();
elasticMapper.registerModule(new JavaTimeModule());
RestClient httpClient = restClientBuilder
.setRequestConfigCallback(requestConfigBuilder ->
requestConfigBuilder.setSocketTimeout(timeout)
.build();
JacksonJsonpMapper jacksonJsonpMapper = new JacksonJsonpMapper(elasticMapper);
RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder();
options.setHttpAsyncResponseConsumerFactory(
new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(
properties.getElastic().getClientBufferSizeByte()
)
);
RestClientOptions restClientOptions = new RestClientOptions(requestOptions);
return new RestClientTransport(httpClient, jacksonJsonpMapper, restClientOptions);
}
@Bean
@Qualifier("increasedBuffer")
public RequestOptions requestOptions() {
RequestOptions.Builder options = RequestOptions.DEFAULT.toBuilder();
options.setHttpAsyncResponseConsumerFactory(
new HttpAsyncResponseConsumerFactory.HeapBufferedResponseConsumerFactory(
clientBufferSize
)
);
return options.build();
} |
We've upgraded to 8.9 in 3.2. Given that there's a workaround (defining your own |
Hello team, Just wanted to bump this closed issue (it was opened when I drafted this) and +1 @fabian-froehlich 's post. We are also using Spring Boot, now 3.1.0-M1, with elasticsearch java (but without spring data elasticsearch) The PR https://github.com/elastic/elasticsearch-java/pull/584/files (on elasticsearch java side) is actually very interesting for SpringBoot users. The reason is: SpringBoot users, very very likely have an object, as bean, as reference, of type The PR from elasticsearch java allows the possibility to take into account the often existing Webclient/RestTemplate, and allow making calls to elasticsearch backend with a client that is "more Spring". However, indeed, the combination SpringBoot 3.1 + elasticsearch java 8.9 seems to yield many issues. |
Problem description
There seems to be a breaking change in the API of the Elasticsearch Java Client in 8.9.0 which was introduced in elastic/elasticsearch-java#584.
Boot's inner class
ElasticsearchTransportConfiguration
insideElasticsearchClientConfigurations
tries to creates anRestClientTransport
by passingTransportOptions
. But due to the change it now expects aRestClientOptions
.There is already work done in
spring-data-elasticsearch
spring-projects/spring-data-elasticsearch@412a2e2. But we do not usespring-data-elasticsearch
in our project.We use
spring-boot-starter-parent
in3.1.2
together with
spring-retry
spring-boot-starter-cache
spring-boot-starter-security
spring-boot-starter-oauth2-resource-server
spring-boot-starter-data-redis
spring-boot-starter-aop
together with
co.elastic.clients.elasticsearch-java
- the new one, not the High-Level-Rest-ClientIs it possible to implement a workaround on my side?
Is it possible to see a fix in the 3.1.X train?
(Similar to elastic/elasticsearch-java#642, not sure which project needs to act)
The text was updated successfully, but these errors were encountered: