Consul

Warning

This module is community maintained and the Lightbend subscription doesn’t cover support for this module. It is also marked as may change. That means that the API, configuration or semantics can change without warning or deprecation period.

Consul currently ignores all fields apart from service name. This is expected to change.

If you are using Consul to do the service discovery this would allow you to base your Cluster on Consul services.

sbt
libraryDependencies += "com.lightbend.akka.discovery" %% "akka-discovery-consul" % "1.0.0-RC2"
Gradle
dependencies {
  compile group: 'com.lightbend.akka.discovery', name: 'akka-discovery-consul_2.12', version: '1.0.0-RC2'
}
Maven
<dependency>
  <groupId>com.lightbend.akka.discovery</groupId>
  <artifactId>akka-discovery-consul_2.12</artifactId>
  <version>1.0.0-RC2</version>
</dependency>

In your application conf add:

akka.discovery {
  method = akka-consul
  akka-consul {

    #How to connect to Consul to fetch services data
    consul-host = "127.0.0.1"
    consul-port = 8500

    # Prefix for consul tag with the name of the actor system / application name,
    # services with this tag present will be found by the discovery mechanism
    # i.e. `system:test` will be found in cluster if the cluster system is named `test`
    application-name-tag-prefix = "system:"

    # Prefix for tag containing port number where akka management is set up so that
    # the seed nodes can be found, an example value for the tag would be `akka-management-port:19999`
    application-akka-management-port-tag-prefix = "akka-management-port:"
  }
}

Notes:

  • Since tags in Consul services are simple strings, prefixes are necessary to ensure that proper values are read.

  • If Akka management port tag is not found on service in Consul the implementation defaults to catalog service port.

The source code for this page can be found here.