Microservice - Spring Cloud Netflix Eureka Service Registry

Let’s go ahead and create our service registry project (terawarehouse-service-discovery). A service registry like Netflix Eureka is a fixed ...


Let’s go ahead and create our service registry project (terawarehouse-service-discovery). A service registry like Netflix Eureka is a fixed point that allows the services to find and communicate with each other without knowing the hostname nor the port but with only the Spring application name. Eureka enables client-side load balancing and with a peer setup each client can act as a server as each client communicates and synchronize with each other.

Let’s start with:

  1. Setting up the Eureka Server - terawarehouse-service-discovery
  2. Create a new SpringBoot project.
  3. Add dependency to spring-cloud-starter-netflix-eureka-server which will provide the necessary dependencies to make this project a service registry server.
  4. Add dependencies spring-boot-starter-web and spring-boot-starter-actuator to let us display the server information.
  5. Annotate SpringBootApplication with EnableEurekaServer.
  6. Create an application.yml configuration file with 2 profiles. Notice that I use different network IP for each profile. Don’t register the eureka server as a client.
    1. instance1 - which we will deploy on our machine
    2. instance2 - which we will deploy on another machine
  7. Run the config server.
  8. Run 2 instances with different profiles.
  9. Check that they are a replica of each other.

Configuring the Client 

  1. Add dependency to spring-cloud-starter-netflix-eureka-client. This will provide the needed dependencies for this project to connect to the service discovery server.
  2. Annotate the SpringBoot class with EnableDiscoveryClient.
  3. And finally add the eureka client information to our project’s configuration:
    eureka.client.register-with-eureka: true
    eureka.client.fetch-registry: true
    eureka.client.service-url.defaultZone:
    http://192.168.1.100:8761/eureka,http://192.168.1.101:8761/eureka
    eureka.client.instance.prefer-ip-address: true
    eureka.client.instance.ip-address: 192.168.1.100
  4. Run the client.
  5. Check if the client properly registers with the eureka server.
Later on, as we introduce new microservices (inventory, order, etc) we can use this service registry for the catalog to send a request to the inventory or simply allow REST communication between them with only the spring application name.

In the next lesson, we will introduce a server-side load balancer that will receive the requests from a client and forward it to the appropriate API using the service discovery information.

I hope everything is clear to this point. You can always ask questions in the comment section below and I’ll be sure to address them.

If you want to get notified when I upload the next video, please subscribe to my channel and hit the bell icon. That will validate that what I’m doing is indeed helpful and will definitely inspire me to create more similar learning videos.

I hope to catch you in the next one. Thanks for watching and have a nice day. Bye.

References

COMMENTS

BLOGGER: 1
  1. What an excellent blog; I especially liked the section where you advised us to write in a less formal tone. A Netflix clone that will help you start your own video streaming business. Video streaming is on the rise, and so is its related app and clone development. Undoubtedly, launching apps and their clones are not as easy as it sounds. Thus, there is a need to find a solution that can help ease the launch of the video streaming app Clone.

    ReplyDelete

mas template
Name

amazon,1,angular,8,bigdata,2,business,1,course-spring,27,courses,6,database,4,docker,3,java,50,kafka,1,keycloak,4,microservices,5,mysql,1,neworking,1,nosql,2,php,1,pinned,2,react,3,server management,7,shared drive,1,spring,7,synology,1,troubleshooting,2,web,1,wordpress,1,
ltr
item
toztech: Microservice - Spring Cloud Netflix Eureka Service Registry
Microservice - Spring Cloud Netflix Eureka Service Registry
https://i.ytimg.com/vi/y-ekG7XGSbg/0.jpg
https://i.ytimg.com/vi/y-ekG7XGSbg/0.jpg
toztech
https://toztech.blogspot.com/2019/10/microservice-spring-cloud-netflix.html
https://toztech.blogspot.com/
https://toztech.blogspot.com/
https://toztech.blogspot.com/2019/10/microservice-spring-cloud-netflix.html
true
2554149350007112447
UTF-8
Loaded All Posts Not found any posts VIEW ALL Readmore Reply Cancel reply Delete By Home PAGES POSTS View All RECOMMENDED FOR YOU LABEL ARCHIVE SEARCH ALL POSTS Not found any post match with your request Back Home Sunday Monday Tuesday Wednesday Thursday Friday Saturday Sun Mon Tue Wed Thu Fri Sat January February March April May June July August September October November December Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec just now 1 minute ago $$1$$ minutes ago 1 hour ago $$1$$ hours ago Yesterday $$1$$ days ago $$1$$ weeks ago more than 5 weeks ago Followers Follow THIS PREMIUM CONTENT IS LOCKED STEP 1: Share to a social network STEP 2: Click the link on your social network Copy All Code Select All Code All codes were copied to your clipboard Can not copy the codes / texts, please press [CTRL]+[C] (or CMD+C with Mac) to copy Table of Content