Custom Spring Boot actuator HealthIndicator
I am reading a book that explains how to create a custom HealthIndicator in Spring Boot, but I don't find it satisfactory. It is calling an external API, and immediately just returns the health status as either up or down based on that.
Often, you need to check for the health of very specific components and services in your application. Or even specific code snippets running somewhere, that other applications may depend on. Furthermore, this can sometimes take a certain time to run, so the health status ought to be "down" while the specific internal code is still running and then return "up" when its up.
TL;DR: How can I create a custom HealthIndicator for specific code parts in my Spring Boot application? It has to be able to check more than once, e.g. if docker calls on the health end point it ought to check if its done yet or not. (my own scenario is that my app is doing some liquibase migration at its startup, and other docker services should wait for it to finish before they start theirs).
3 Replies
⌛
This post has been reserved for your question.
Hey @Steadhaven! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
There is a practice called a Heartbeat for the application periodically telling someone that he is still "alive". For long running tasks you could use in-code a Watchdog (org.apache.commons.exec.Watchdog). Also a CountDownLatch (java.util.concurrent.CountDownLatch) could help notify stages of long running blocks.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.
💤
Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.