§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).
§Dependency
To use this feature add the following in your project’s build:
In Maven:
<dependency>
<groupId>com.lightbend.lagom</groupId>
<artifactId>lagom-javadsl-akka-discovery-service-locator_${scala.binary.version}</artifactId>
<version>${lagom.version}</version>
</dependency>
In sbt:
import com.lightbend.lagom.core.LagomVersion
libraryDependencies += "com.lightbend.lagom" %% "lagom-javadsl-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.
§Configuration
The Guice module AkkaDiscoveryServiceLocatorModule will be added by default to your project, but will only wire in the AkkaDiscoveryServiceLocator when running in production mode.
In development, your Lagom application will keep using the Lagom’s dev-mode ServiceLocator
.
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.