In the previous part of this article, Spring Cloud: How to Implement Service Discovery (Part 1),  we saw the basics of Service Discovery in the context of Spring Cloud. We have seen that the Netflix OSS Eureka component is still the main choice. In this post, we are going to discuss some Eureka additional topics, such as:

Java client API
REST API
Secure the discovery server and the client services
Combine Service Discovery with Distributed Configuration

Service Discovery: Client Java API 

In the examples in the first part of this article,  the registering and fetching features were running under the hood and we have only seen the results of testing the whole architecture by calling a client REST endpoint. There is also a way to interact with the Eureka API programmatically, by using Java method calls. A possible choice would be to use the EurekaClient class. For example, if we want to get all the instances of a service identified by a particular ID, we could write the following code, supposing we have a client implemented as a Spring Boot application exposing REST services:

Leave a Reply

Your email address will not be published. Required fields are marked *