-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Possibility for Spring Data ElasticSearch to support Spring RestTemplate and Spring Webflux Webclient #2604
Comments
Thanks for notifying about this change, I'll have a look of how this can be integrated or extended into Spring Data Elasticsearch.
It's not about the classes being on the classpath, but where the instance of these are created , and Spring itself does not create anything of this, but Spring Boot does. Spring Boot creates such beans if no other library, part of the application has not created one during the startup. For the combination of Spring Boot and Spring Data Elasticsearch this means, that Spring Boot will provide beans that Spring Data Elasticsearch has not yet provided. For the use of http clients that means, that a custom client would need to be created in Spring Data Elasticsearch and be provided as a bean (which definitely is possible) and then it could be used by other components as well. Spring Data Elasticsearch cannot use beans provided by Spring Boot, Boot beans are created/initialized after Spring Data Elasticsearch beans. And I did not yet check what clients will be supported, with a first glance I did not see that Webflux webclient is supported, and even if it were supported as a client, please note, that this would not provide a reactive client handling at all, for this all the calls in the Elasticsearch client API need reactive versions. But I'll have a look of what can be used for Spring Data Elasticsearch of this. |
Thank you |
I also have a
In which I would really hope spring data elasticsearch can leverage. Thank you in advanced @sothawo if you can help on this |
This seems not to be part of the current version 8.8.1 of the Elasticsearch client. |
It is now available with the latest 8.9! |
Saw the integration with version 8.9, thank you again @sothawo Is this feature "doable"? |
Might be. The official docs do not mention or explain this, so it would be down to go into the implementation and check what can be done. |
I am also reading the code, and trying to see how to integrate with WebClient from Spring Data Elasticsearch. I saw those: Do you think those examples are helpful? |
Any luck on this please? |
With #2702 it is now possible to provide a custom |
Thanks! let me try to pass the WebClient to this. |
Hi @patpatpat123, any luck on integrating it with WebClient? |
Upvoting this. Could we please have an example of an integration with existing WebClient please? |
Sorry, I don't have the time to write another It would not give you a true reactive client to access Elasticsearchanyway, as it would be just plugged into the normal Transport interface which has no reactive methods at all, only the imperative and async ones which we already use for the reactive implementation. |
Expected Behavior
In a Spring project, there is a very high likelyhood a Spring RestTemplate, Spring WebFlux Webclient is already on the classpath.
it will be a great improvement for this project, instead of using the default Elasticsearch Java http client, this project can use Spring RestTemplate, Spring WebFlux Webclient that is on a Spring project.
This PR opens this possibility for this project: https://github.com/elastic/elasticsearch-java/pull/584/files
Just to avoid any misunderstanding, this is not an ask to support each and every http client possible and imaginable. Both Spring RestTemplate and Spring Webflux Webclient are very common, and usually present in a default Spring, SpringBoot project. It will be great to be able to leverage those existing clients, now ElasticSearch Java allows it.
Just to avoid misunderstanding, this is not an ask to bring back to life the already deprecated High Level Rest Client https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.resthighlevelclient or the already deprecated Reactive Client https://docs.spring.io/spring-data/elasticsearch/docs/current/reference/html/#elasticsearch.clients.reactive It is to use the ElasticSearch Java, but with Spring RestTemplate, Spring Webflux Webclient, now this PR offers the possibility to do so
https://github.com/elastic/elasticsearch-java/pull/584/files
Current Behavior
Currently, Spring Data Elasticsearch uses Elasticsearch Java, which uses apache http client.
A great improvement has been made by Elasticsearch Java to allow the support of other http clients.
https://github.com/elastic/elasticsearch-java/pull/584/files
This is an equally great opportunity for this project to be able to wire the usual Spring RestTemplate / Spring WebFlux Webclient instead.
While one can do this replacement on his own, rewriting the code on the SpringBoot/Spring data elasticsearch project, it will be a great improvement if this project can help with the boiler plate code and the configuration, so the application can just configure and ready the use of the http client
Context
How has this issue affected you?
It is usual for a SpringBoot, Spring project to have a preconfigured, tested, tuned Spring RestTemplate Spring Webflux Webclient. However, this project, after the deprecations, does not allow the use of them. This recent PR from Elasticsearch Java is a game changer for Spring based elasticsearch applications.
What are you trying to accomplish?
In most of SpringBoot projects, there is a Webclient, a RestTemplate , which has preconfigured logging, monitoring, circuit breakers, etc... (all part of Spring portfolio) Being able to use those clients within Spring data elasticsearch would be a great plus. Thank you
The text was updated successfully, but these errors were encountered: