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

  • Microservices: Good for Developers' Mental Health
  • An Overview of Health Check Patterns
  • Build a Stateless Microservice With GitHub Copilot in VSCode
  • From Prompt to Running Microservice: ServiceBricks Step-By-Step

Trending

  • The Modern Data Stack Is Overrated — Here’s What Works
  • Java’s Next Act: Native Speed for a Cloud-Native World
  • A Guide to Container Runtimes
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  1. DZone
  2. Data Engineering
  3. Data
  4. Helidon: Microservice Health Check

Helidon: Microservice Health Check

A health check of our Microservice is part of Microprofile specification. We don't need to write anything special with Helidon.

By 
Thamizh Arasu user avatar
Thamizh Arasu
·
Dec. 27, 19 · Analysis
Likes (1)
Comment
Save
Tweet
Share
3.0K Views

Join the DZone community and get the full member experience.

Join For Free

Helidon health check graphic

Learn how to perform a health check with Helidon.

A health check of our Microservice is part of Microprofile specification. We don't need to write anything special with Helidon. All the health API will be available out of the box in our implementation.

Health Check APIs

There are three endpoints are available as part of the specification to check the health of our microservices. These APIs will be used by the 3rd party application/integration tools to check the health. Those APIs are as follows,

/health /health/live /health/ready

/Health

This is the top-level API to check the health of our microservice. Apart from the liveness and readiness of our application, we will also get more internal information about services like the following,

/Health/Live

We can check the liveness of our application using this end-point. Any micro profile compliant framework should offer this implementation out of the box. Helidon will also offer such end-point and return meaningful information. In some cases, we may need to customize the liveness end-points.

In such use-cases, we need to provide an implementation of the HealthCheck interface with @Liveness annotation. See the code below.

//Custom Liveness implementation @Liveness @ApplicationScoped 
//public class DailyApiLiveness implements HealthCheck { 
//@Override public HealthCheckResponse call() { return 
//HealthCheckResponse.named("DailyAPI Liveness") .up() 
//.withData("time", System.currentTimeMillis()) .build(); } }

/Health/Ready

This end-point is similar to the above live end-point. The only difference is the @Readiness annotation instead of @Liveness. We can add our custom logic to calculate the readiness to expose the real value to our partners or integration solutions. Please see the sample code below,

//We can add our custom logic to calculate the real readiness and 
//return the response //accordingly. @Readiness @ApplicationScoped 
//public class DailyApiReadiness implements HealthCheck { 
//@Override public HealthCheckResponse call() { return 
//HealthCheckResponse.named("DailyAPI Readiness") .up() .build(); } }


Once everything is set properly, we will get the following response when we access the /health API.

{ "outcome": "UP", "status": "UP", "checks": [ { "name": "DailyAPI Liveness", 
  "state": "UP", "status": "UP", "data": { "time": 1571677530451 } }, 
{ "name": "DailyAPI Readiness", "state": "UP", "status": "UP", "data": 
 { "time": 1571677530460 } }, { "name": "deadlock", "state": "UP", "status": 
  "UP" }, { "name": "diskSpace", "state": "UP", "status": "UP", "data": 
  { "free": "96.31 GB", "freeBytes": 103412359168, "percentFree": 
       "41.23%", "total": "233.57 GB", "totalBytes": 250790436864 } }, 
   { "name": "heapMemory", "state": "UP", "status": "UP", "data": 
    { "free": "194.89 MB", "freeBytes": 204357016, "max": "1.78 GB", 
     "maxBytes": 1908932608, "percentFree": "98.02%", "total": "231.00 MB", 
     "totalBytes": 242221056 } } ] }


I hope you have enjoyed the article. Let me know if you need any improvement or suggestion on this topic.

Happy coding!


Further Reading

MicroProfile: What You Need to Know

Thoughts on Quarkus

Health (Apple) microservice

Published at DZone with permission of Thamizh Arasu, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Microservices: Good for Developers' Mental Health
  • An Overview of Health Check Patterns
  • Build a Stateless Microservice With GitHub Copilot in VSCode
  • From Prompt to Running Microservice: ServiceBricks Step-By-Step

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!