Akka Discovery Integration

§Using Akka Discovery

Lagom 1.4.12 contains a backport of Akka Discovery Service Locator, a component introduced in Lagom 1.5.1. It provides a built-in integration with Akka Discovery throught a ServiceLocator implmentation that wraps Akka Discovery. This is the recommended implementation for production specially for users targeting Kubernetes and DC/OS (Marathon).


To use this feature add the following in your project’s build:

import com.lightbend.lagom.core.LagomVersion

libraryDependencies += "com.lightbend.lagom" %% "lagom-scaladsl-akka-discovery-service-locator" % LagomVersion.current

The example above uses LagomVersion.current in order to guarantee that dependency stays aligned with your current Lagom plugin version.


Once you have it in your project you can add the component to your LagomApplicationLoader.

import com.lightbend.lagom.scaladsl.devmode.LagomDevModeComponents
import com.lightbend.lagom.scaladsl.server._
import com.lightbend.lagom.scaladsl.akka.discovery.AkkaDiscoveryComponents

class HelloApplicationLoader extends LagomApplicationLoader {

  override def load(context: LagomApplicationContext) =
    new HelloApplication(context) with AkkaDiscoveryComponents

  override def loadDevMode(context: LagomApplicationContext) =
    new HelloApplication(context) with LagomDevModeComponents


Next, you will need to choose one of the available Akka Discovery implementations and configure it in your application.conf file. Consult the Akka Discovery documentation for further instructions.

Note: this component was previous published as an independent library. If you have it on your classpath it’s recommended to remove it and use the one being provided by Lagom directly.

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.