Akka Management: Adding liveness check to my application

I am working with Akka and have to add some custom implementation to Liveness check for a usecase.

Following the Akka documentation at Configuring health checks, I added the following configuration to my application:

akka {
  management {
    health-checks {
      liveness-checks {
        cluster-liveness = "ie.fd.cpoi.acl.liveness.LivenessCheck"
      }
    }
  }
}

I have created the class, implementing Supplier<CompletionStage<Boolean>> as:

package ie.fd.cpoi.acl.liveness

import akka.actor.ActorSystem
import org.slf4j.{Logger, LoggerFactory}

import scala.concurrent.Future

class LivenessCheck(system: ActorSystem) extends (() => Future[Boolean]) {

  val logger: Logger = LoggerFactory.getLogger("LivenessCheck")

  override def apply(): Future[Boolean] = {
    logger.info("Making call to a dependent system here. We need to restart the app if its down")
    Future.successful(false)
  }
}

But somehow Akka is not picking up the liveness check:

[INFO ] 2021-10-04 16:20:45.164+0000 [cpoi-ha-akka.actor.default-dispatcher-6] a.m.i.HealthChecksImpl - Loading liveness checks []

Can somene help me with what I am missing here?

Have you included the dependency akka-management-cluster-http ?

Hey Patrik, yes have included the dependencies.

val AkkaManagementVersion = "1.1.1"
libraryDependencies ++= Seq(
  "com.lightbend.akka.management" %% "akka-management" % AkkaManagementVersion,
  "com.lightbend.akka.management" %% "akka-management-cluster-http" % AkkaManagementVersion
)

Are you sure it shouldn’t be “cluster-membership” instead of “cluster-liveness” in the .conf file?