Skip to Content
Mastering Spring Cloud
book

Mastering Spring Cloud

by Piotr Mińkowski
April 2018
Intermediate to advanced content levelIntermediate to advanced
432 pages
10h 38m
English
Packt Publishing
Content preview from Mastering Spring Cloud

Using discovery client programmatically

After client application startup, the list of registered services is fetched from the Eureka Server automatically. However, it might turn out to be necessary to use Eureka's client API programmatically. We have two possibilities:

  • com.netflix.discovery.EurekaClient: It implements all HTTP API methods exposed by the Eureka Server, which have been described in the Eureka API section.
  • org.springframework.cloud.client.discovery.DiscoveryClient: It is a Spring Cloud alternative to the native Netflix EurekaClient. It provides a simple, generic API useful for all of the discovery clients. There are two methods available, getServices and getInstances:
private static final Logger LOGGER = LoggerFactory.getLogger(ClientController.class); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Microservices with Spring Boot and Spring Cloud - Second Edition

Microservices with Spring Boot and Spring Cloud - Second Edition

Magnus Larsson

Publisher Resources

ISBN: 9781788475433Supplemental Content