What's the difference between EnableEurekaClient and EnableDiscoveryClient?
Asked Answered
T

5

140

In some applications, I saw people are using @EnableEurekaClient. And some other example applications are using @EnableDiscoveryClient.

Is there any difference between these two?

Tallowy answered 12/8, 2015 at 22:8 Comment(0)
M
239

There are multiple implementations of "Discovery Service" (eureka, consul, zookeeper). @EnableDiscoveryClient lives in spring-cloud-commons and picks the implementation on the classpath. @EnableEurekaClient lives in spring-cloud-netflix and only works for eureka. If eureka is on your classpath, they are effectively the same.

Madancy answered 13/8, 2015 at 16:11 Comment(4)
Question : Will both of above mentioned annotations enable Ribbon-enabled interceptor injected into RestTemplate? Any difference in behavior? I noticed that in previous Spring Cloud implementations @LoadBalanced was automatically applied, but in current version, it is required explicitly. Thank you.Lite
Yes. There is no difference. The load balanced annotation has been required for a long time.Madancy
Why would someone want to use @EnableEurekaClient over the more general @EnableDisocveryClient? Wouldn't that bind them to the eureka implementation and make it harder to switch SD backends in the future?Androgyne
Yes. The only answer is if they want to be clear and enforce eureka.Madancy
B
7

Discovery service concept in spring cloud is implemented in different ways like Eureka, consul, zookeeper etc. If you are using Eureka by Netflix then @EnableEurekaClient is specifically for that. But if you are using any other service discovery including Eureka you can use @EnableDiscoveryClient.

Busra answered 4/5, 2019 at 12:13 Comment(1)
perfect explainationDrool
D
3

In terms of its practicality and simplicity, if the registered center is eureka, then @EnableEurekaClient is recommended. If it is another registration center, @EnableDiscoveryClient is recommended.

Dogger answered 13/12, 2019 at 14:18 Comment(0)
S
3

@EnableEurekaCient will initilize the service discovery using eureka server, its like explicitly specifying to use EUREKA

While @EnableDiscovery Client will register dicovery service using the jar available in classpath like consul, Eureka, Kubernetes.

Skewer answered 5/1, 2022 at 14:52 Comment(0)
A
1

@EnableEurekaClient works only for Eureka if we use @EnableDiscoveryClient we can use any discovery client like Consul other than Eureka

Addict answered 20/9, 2021 at 6:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.