Spring boot microservices with Eureka server
Today one of most popular topic is microservice architecture. Microservice can be write using Nodejs, Java, Python, etc.. In this article i will explain Writing java microservice using Spring boot and intercommunication between those microservice using Eureka service discovery server.
Diagram 1 will explain .
- Client send the request to API Gateway.
- API gateway route that request to the discovery service.
- Discovery service will route request to consumer service.
- Consumer service send database service request to discover service.
- Discover service will send request to database service.
- Database service response and discover service will response to the consumer service.
- Consumer service respond to the discover service and respond to the API gateway.
- API gateway respond to the Client.
What is service discovery ?
Service discovery is the automatic detection of service offered by service cluster.In this example i’m using Eureka discovery server as a microservice.
How to setup Eureka server as a microservice ?
Create simple maven project and add following dependencies to pom.xml file.
- Add parent tag
- Add netflix eureka server dependancy.
- Add spring cloud dependency under dependency management tag.
Create application.java class file and add following annotations.
Create property file and add following properties.
Now try on http://localhost:8090/ . You should get following result.