liveBook · Manning

Wellness check

As explained in Quarkus in Action

A wellness check reports broader application or dependency health conditions that may indicate problems without necessarily showing that the process is dead or unable to serve requests.

A wellness check reports application or dependency conditions that may indicate trouble without proving that the process is dead or unable to serve requests. Unlike liveness and readiness checks, it supports monitoring and human investigation without automatically restarting the application or withholding traffic. section 10.2

Use wellness checks when a condition matters operationally but does not justify immediate automated action:

  • Report an empty inventory as DOWN even though the Inventory service itself may still be running. section 10.2.1
  • Expose less serious problems for custom monitoring tools or manual operators. section 10.2
  • Keep liveness, readiness, and startup checks focused on process continuity, traffic acceptance, and initialization. section 10.2

Inventory count check

Implement HealthCheck, annotate the class with SmallRye's @Wellness, query the repository, and set the response status from the result. A car count above zero returns UP; zero returns DOWN. Include the count as response data so operators can see why the status changed. section 10.2.1

Listing 10.3 Wellness check reporting DOWN if the inventory is empty
package org.acme.inventory.health;

import io.smallrye.health.api.Wellness;
import jakarta.inject.Inject;
import org.acme.inventory.repository.CarRepository;
import org.eclipse.microprofile.health.HealthCheck;
import org.eclipse.microprofile.health.HealthCheckResponse;

@Wellness
public class CarCountCheck implements HealthCheck {

    @Inject
    CarRepository carRepository;

    @Override
    public HealthCheckResponse call() {
        long carsCount = carRepository.findAll().count();
        boolean wellnessStatus = carsCount > 0;
        return HealthCheckResponse.builder()
            .name("car-count-check")
            .status(wellnessStatus)  #1
            .withData("cars-count", carsCount)  #2
            .build();
    }
}

The complete CarCountCheck implementation shows the @Wellness annotation, HealthCheck contract, repository query, status selection, and cars-count diagnostic field. section 10.2.1

Listing 10.5 The wellness check when the inventory is empty
{
    "status": "DOWN",
    "checks": [
        {
            "name": "car-count-check",
            "status": "DOWN",
            "data": {
                "cars-count": 0
            }
        }
    ]
}

The failing response shows the aggregate DOWN status and the cars-count value of zero when the inventory is empty. section 10.2.1

How Quarkus in Action covers it

How deep it goes
Defines wellness beside liveness, readiness, and startup, then demonstrates a repository-backed custom check and its JSON responses.
Examples
Demonstrates an empty car inventory, Health UI output, HTTP JSON responses, and a CarCountCheck backed by CarRepository.
What it assumes
Assumes a Java application with Quarkus health support and a repository or dependency whose condition can be evaluated.
What you can do after
Build it from scratch with Quarkus and SmallRye Health by implementing HealthCheck, annotating it with @Wellness, and querying its endpoint.
How it connects
Connects MicroProfile Health, SmallRye Health, Quarkus, liveness checks, readiness checks, startup checks, and custom health groups.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Quarkus in Action. The section links point to the parts of the book it draws on.