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); ...

Get Mastering Spring Cloud now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.