In some applications, I saw people are using #EnableEurekaClient. And some other example applications are using #EnableDiscoveryClient.
Is there any difference between these two?
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.
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.
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.
#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.
#EnableEurekaClient works only for Eureka if we use #EnableDiscoveryClient we can use any discovery client like Consul other than Eureka
Related
From the announcement of the Spring Cloud Greenwich release, see https://spring.io/blog/2019/01/23/spring-cloud-greenwich-release-is-now-available, I noticed that is recommended to replace Netflix Ribbon with Spring Cloud Loadbalancer.
Does that mean that Spring Cloud Loadbalancer can be use by a client to connect to services registered in Netflix Eureka without using Netflix Ribbon?
I have tried to find documentation and/or examples that describes how to do that, but I haven't find any.
You can find a sample in the tests of Spring Cloud Loadbalancer.
So what you'll have to do is the following. You'll have to annotate a configuration class with #LoadBalancerClient (or wrap it in #LoadBalancerClients if you want to have multiple clients) where you specify your client's name and its config class.
In that load balancer client's config class you'll need to create a bean which will return a load balancer. In the test it's the RoundRobinLoadBalancer.
You can then use that load balancer bean to pick the next service instance, which in turn can be used to make the call to your other service.
See this test: https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-loadbalancer/src/test/java/org/springframework/cloud/loadbalancer/core/LoadBalancerTest.java#L132
I am exploring options to have Netflix Zuul as API Gateway for my Microservices in Cloud Foundry. I am not able to see Zuul option in CF marketplace (I see Apigee integration with CF Service Broker API). I wanted to use Netflix Zuul as API Gateway, If I spin up Zuul as regular application it goes behind HA Proxy/Go Router, I think that is not right thing to do. May be I should implement Service Broker API and create Zuul as a service in CF marketplace. Can someone please through some light on this.I it involved task to make Netfliz Zuul as a Service Broker in CF? I see Eureka in Market place but not Zuul. Dont know why it is like this.. Thank you.
That will be very helpful if you can come up with zuul managed service in PCF.
Currently what we do is we use spring boot + spring cloud application to develop api gateway. We have to use spring-cloud-starter-zuul dependency. Then ahead we need to register gateway app with Netflix Eureka service registry.
Lastly we refer registered Zuul api gateway in all our client api applications.
Good luck with cf marketplace Zuul managed service :)
We are moving our large set of eureka based microservices to consul based discovery.
There was one feature of the eureka version of spring cloud that we were used. You could register a specific hostname such as "hostname: blah".
Is a capability like that present in the spring cloud consul version?
You can set spring.cloud.consul.discovery.hostname. It's not documented, but it should show in IDE auto-complete with the note on what it is for.
See ConsulDiscoveryProperties.
We're migrating to Kubernetes and many of our services are using Hystrix which expose a stream of server sent event data consumed by Turbine and visualized by a Hystrix Dashboard. I'd like to implement a service discovery plugin to Turbine which auto discovers our Hystix streams running on Kubernetes.
Would it be a good idea to use labels for this? I.e. define a label that includes the path to the hystrix stream for each pod using Hystrix?
If labels are not a good idea, what would be?
I had the same problem and I created a little project to address it.
essentially I implemented a hystric instance discovery class to work with kubernetes services.
You can find my project here.
This projects is in its infancy so bugs are likely. Feedback it welcome.
Thanks
Raffaele
How about making Hystrix a Kubernetes service?Kubernetes has two suggested ways to discover services: https://github.com/kubernetes/kubernetes/blob/master/docs/user-guide/services.md#discovering-services
When deploying Spring Cloud-enabled microservices on JBoss, we have to use a contextPath. Turbine doesn't seem to fetch the contextPath from eureka and eureka doesn't seem to ask it to the microservices.
Some more details:
Every microservice has its own Jboss, and its own contextPath defined in the war, as such:
hostname1:port1/products
hostname2:port2/users
hostname3:port3/orders
Endpoints (actuator and our own) are exposed after the contextPath (not using management.context-path):
hostname1:port1/products/env
hostname1:port1/products/info
hostname1:port1/products/books
hostname1:port1/products/books/123
Eureka only cares about the hostname and port. It allows us to define a different UrlPath to info and health although this is not part of the data Turbine needs to get to hystrix.stream:
eureka:
instance:
statusPageUrlPath: ${server.contextPath}/info
healthCheckUrlPath: ${server.contextPath}/health
Is there a way to tell Turbine which contextPath is used for which application? These are different per application so a cluster-wide fix described here wouldn't be sufficient I suppose.
You can only view one cluster at a time in normal turbine. With spring-cloud-netflix-hystrix-amqp we aggregate all statistics via rabbitmq (not http), so you can see everything at once.