This project shows a simple implementation of Spring Cloud Netflix Eureka and Spring Cloud OpenFeign.
Eureka is used as a registry for all started services and Feign is used to call another service, just by its name. The combination of Eureka and Feign also provides a load balancing to distribute the requests to all available instances of a service.
- Clone this repository
- Run
mvn clean install
in the root dir
- Start Eureka by
cd
intospring-cloud-eureka
and runmvn spring-boot:run
- Start multiple instances of the city service by
cd
intocity-service
and runmvn spring-boot:run
multiple times in different terminal sessions - Start the address service by
cd
intoaddress-service
and runmvn spring-boot:run
- Open
http://localhost:8761
to see if the services are listed in Eureka - Check the randomly assigned serverport of the address-service in the console
- Send a REST request to the address-service:
GET http://localhost:PORT/addresses/Sample
The address-service calls each time the city-service to determine the name of a city by the given country and postalcode. You also should see this requests in the logs. Each time another instance of city-service should be requested.