spring-cloud/spring-cloud-netflix

Support Spring RestClient as TransportClientFactory and make it the default implementation

ZIRAKrezovic opened this issue ยท 6 comments

Describe the solution you'd like

Complements: #4255

Consider implementing RestClientTransportClientFactory to complement existing RestTemplateClientFactory (not exactly based on RestTemplate), which is kind of deprecated.

https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-restclient

See note: https://docs.spring.io/spring-framework/reference/integration/rest-clients.html#rest-resttemplate

Makes sense.

FYI, PR: #4281

Thanks, @injae-kim. @heowc is working on this now.

Update: there's still some work related to adjusting config in TransportClientFactories, that I'm working on here that has to be modified in order for RestClient to be used as the default.

heowc commented

Update: there's still some work related to adjusting config in TransportClientFactories, that I'm working on here that has to be modified in order for RestClient to be used as the default.

Thanks for looking into it. I think it can be modified with RestClient.Builder, but I'm curious as to why it needs to be added. ๐Ÿค”

We need to integrate with Netflix's native way of handling connections through TransportClientFactories, otherwise there'll be a TransportException.

com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
	at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:76) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:828) ~[eureka-client-2.0.4.jar:2.0.4]
	at com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:125) ~[eureka-client-2.0.4.jar:2.0.4]
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:572) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.run$$$capture(FutureTask.java:317) ~[na:na]
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java) ~[na:na]