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
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

  • How Spring and Hibernate Simplify Web and Database Management
  • Functional Endpoints: Alternative to Controllers in WebFlux
  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4

Trending

  • AI’s Role in Everyday Development
  • Fixing Common Oracle Database Problems
  • Teradata Performance and Skew Prevention Tips
  • Scaling Mobile App Performance: How We Cut Screen Load Time From 8s to 2s
  1. DZone
  2. Coding
  3. Frameworks
  4. Using Netflix Eureka With Spring Cloud/Spring Boot Microservices (Part 1)

Using Netflix Eureka With Spring Cloud/Spring Boot Microservices (Part 1)

This simple example shows how to use Eureka as a service registry for Spring Boot microservices, and what this would look like when deployed in Docker containers.

By 
Kevin Hooke user avatar
Kevin Hooke
·
Jan. 27, 18 · Code Snippet
Likes (7)
Comment
Save
Tweet
Share
31.6K Views

Join the DZone community and get the full member experience.

Join For Free

I've been taking a look at this article on using Spring Cloud's integration/support for Netflix Eureka. I've started to put together a simple example using Eureka as a service registry for a couple of Spring Boot services, and what this would look like if deployed in Docker containers.

So far I've created the initial service that uses Spring Cloud's @EnableEurekaServer annotation to start up the Eureka service.

Jumping ahead of the instructions, by default if you run this app it will attempt to reach out and find a local running Eureka server and register with it, but since this app is the Eureka server, you need to add config to tell the app not to do this by default. Otherwise you'll see errors like:

com.sun.jersey.api.client.ClientHandlerException :  java.net.ConnectException : Connection refused
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187) ~[jersey-apache-client4-1.19.1.jar:1.19.1]
at com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123) ~[jersey-client-1.19.1.jar:1.19.1]
at com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27) ~[eureka-client-1.6.2.jar:1.6.2]

Adding the recommended config per the article:

Now when I start up I see this:

2017-04-11 22:23:17.040INFO 37607 - o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2017-04-11 22:23:17.100INFO 37607 - com.netflix.discovery.DiscoveryClient: Initializing Eureka in region us-east-1
2017-04-11 22:23:17.101INFO 37607 - com.netflix.discovery.DiscoveryClient: Client configured to neither register nor query for data.
2017-04-11 22:23:17.110INFO 37607 -com.netflix.discovery.DiscoveryClient: Discovery Client initialized at timestamp 1491974597110 with initial instances count: 0
2017-04-11 22:23:17.192INFO 37607 - c.n.eureka.DefaultEurekaServerContext: Initializing ...
2017-04-11 22:23:17.195INFO 37607 - c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://localhost:8761/eureka/]
2017-04-11 22:23:17.359INFO 37607 - c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2017-04-11 22:23:17.359INFO 37607 - c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2017-04-11 22:23:17.359INFO 37607 - c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2017-04-11 22:23:17.359INFO 37607 - c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2017-04-11 22:23:22.479INFO 37607 - c.n.eureka.cluster.PeerEurekaNodes : Replica node URL:http://localhost:8761/eureka/
2017-04-11 22:23:22.486INFO 37607 - c.n.e.registry.AbstractInstanceRegistry: Finished initializing remote region registries. All known remote regions: []
2017-04-11 22:23:22.486INFO 37607 - c.n.eureka.DefaultEurekaServerContext: Initialized

Hitting http://localhost:8761 I get the fancy Eureka dashboard:

Looks good so far! More to come later.

The GitHub repo for the code so far is here.

Spring Framework

Published at DZone with permission of Kevin Hooke, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How Spring and Hibernate Simplify Web and Database Management
  • Functional Endpoints: Alternative to Controllers in WebFlux
  • Graceful Shutdown: Spring Framework vs Golang Web Services
  • Actuator Enhancements: Spring Framework 6.2 and Spring Boot 3.4

Partner Resources

×

Comments

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: