DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workkloads.

Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • A New Era Of Spring Cloud
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Migration of Microservice Applications From WebLogic to Openshift
  • Google Cloud Pub/Sub: Messaging With Spring Boot 2.5

Trending

  • Internal Developer Portals: Modern DevOps's Missing Piece
  • Beyond Linguistics: Real-Time Domain Event Mapping with WebSocket and Spring Boot
  • Streamlining Event Data in Event-Driven Ansible
  • Unlocking AI Coding Assistants Part 1: Real-World Use Cases
  1. DZone
  2. Coding
  3. Frameworks
  4. Netflix Eureka Discovery – Microservices

Netflix Eureka Discovery – Microservices

Learn about using Netflix Eureka with microservices to monitor and maintain a registry of all the microservices in the ecosystem.

By 
Sovan Misra user avatar
Sovan Misra
·
Aug. 29, 18 · Tutorial
Likes (14)
Comment
Save
Tweet
Share
48.6K Views

Join the DZone community and get the full member experience.

Join For Free

In the headline, we saw three buzzwords:

  1. Microservices
  2. Netflix Eureka
  3. Discovery (Registry)

What Is a Microservice?

In simple words, microservice(s) are clusters of small applications that work together in coordination to provide a complete solution.

When we say a lot of small applications running independently together, then they will all have their own URLs and ports. In that scenario, it would be very cumbersome to maintain all these microservices to run in synchronization, and more importantly, with monitoring. This problem will increase manifold when we start implementing load balancers.

To solve this issue, we need a tool that will monitor and maintain the registry of all the microservices in the ecosystem.

What Is Netflix Eureka?

This is a tool provided by Netflix to provide a solution to the above problem. It consists of the Eureka Server and Eureka clients. Eureka Server is in itself a microservice to which all other microservices registers. Eureka Clients are the independent microservices. We will see how to configure this in a microservice ecosystem.

I will be using Spring Boot to create a few microservices which will act as Eureka Clients and a Discovery Server which will be a Eureka Server. Here is the complete project structure:

microservice1

Let’s Discuss the Eureka Discovery Server

This is the Eureka Server, and for that, we have to include a Eureka dependency in the project. Below is the pom.xml for Eureka Discovery Server.

microService2

Also, we need to update the properties file for this project to indicate that is a discovery server and not a client.

eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false

To bind the discovery application to a specific port and name the application, we need to add the following, as well:

server.port=8000
spring.application.name=DiscoveryServer

microService3

One last thing to do is to annotate the Spring Boot application to enable this as a Eureka Server. To do so, we need to add  @EnableEurekaServer .

microService4

Boot up the application we will see a UI provided by Eureka to list all the servers that get registered. But, at this point, we have none!

microService5

Now, let’s add a few microservices to the ecosystem and register them to the discovery server. For this, we also need to add the dependencies required in each service and register them to the server. We will see how in the details below.

I have created three simple microservices (microservice1, microservice2, microservice3) with Spring Boot and each one running on its own port (8002, 8003 and 8004).

microService6

As a client, it should register itself to the server, and that happens in the property file, as below.

microService7

The main application will be annotated with @EnableEurekaClient in each microservice.

microService8

Boot up this application to run on port 8004 and it will automatically register itself to the discovery server. In a similar manner, I have created two more microservices and registered them on the discovery server.

microService9

We can see that three servers are running in the ecosystem and we can monitor the status of these servers, too.

This eases the monitoring of all the servers and their replicas in case we are using a load balancer.

I hope this will help you get started using Discovery Server and Clients using Eureka.

Reference the Git repository containing the codes for all the projects in this application!

microservice Discovery (law) Spring Framework application Spring Boot

Published at DZone with permission of Sovan Misra, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • A New Era Of Spring Cloud
  • Distributed Tracing System (Spring Cloud Sleuth + OpenZipkin)
  • Migration of Microservice Applications From WebLogic to Openshift
  • Google Cloud Pub/Sub: Messaging With Spring Boot 2.5

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!