Consul
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.
Project Info
Project Info: Akka Discovery Consul | |
---|---|
Artifact | com.lightbend.akka.discovery
akka-discovery-consul
1.0.10
|
JDK versions | Adopt OpenJDK 8 with Hotspot Adopt OpenJDK 11 with Hotspot |
Scala versions | 2.11.12, 2.12.13, 2.13.5 |
License | |
Readiness level |
Since 0.15.0, 2018-07-02
|
Home page | https://akka.io/ |
API documentation | |
Forums | |
Release notes | GitHub releases |
Issues | GitHub issues |
Sources | https://github.com/akka/akka-management |
- sbt
val AkkaManagementVersion = "1.0.10" libraryDependencies += "com.lightbend.akka.discovery" %% "akka-discovery-consul" % AkkaManagementVersion
- Gradle
def versions = [ AkkaManagementVersion: "1.0.10", ScalaBinary: "2.12" ] dependencies { implementation "com.lightbend.akka.discovery:akka-discovery-consul_${versions.ScalaBinary}:${versions.AkkaManagementVersion}" }
- Maven
<properties> <akka.management.version>1.0.10</akka.management.version> <scala.binary.version>2.12</scala.binary.version> </properties> <dependencies> <dependency> <groupId>com.lightbend.akka.discovery</groupId> <artifactId>akka-discovery-consul_${scala.binary.version}</artifactId> <version>${akka.management.version}</version> </dependency> </dependencies>
akka-discovery-consul
can be used with Akka 2.5.31 or 2.6.9 or later. You have to override the following Akka dependencies by defining them explicitly in your build and define the Akka version to the one that you are using. Latest patch version of Akka is recommended and a later version than 2.6.9 can be used.
- sbt
val AkkaVersion = "2.6.9" libraryDependencies ++= Seq( "com.typesafe.akka" %% "akka-cluster" % AkkaVersion, "com.typesafe.akka" %% "akka-discovery" % AkkaVersion )
- Gradle
def versions = [ AkkaVersion: "2.6.9", ScalaBinary: "2.12" ] dependencies { implementation "com.typesafe.akka:akka-cluster_${versions.ScalaBinary}:${versions.AkkaVersion}" implementation "com.typesafe.akka:akka-discovery_${versions.ScalaBinary}:${versions.AkkaVersion}" }
- Maven
<properties> <akka.version>2.6.9</akka.version> <scala.binary.version>2.12</scala.binary.version> </properties> <dependencies> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-cluster_${scala.binary.version}</artifactId> <version>${akka.version}</version> </dependency> <dependency> <groupId>com.typesafe.akka</groupId> <artifactId>akka-discovery_${scala.binary.version}</artifactId> <version>${akka.version}</version> </dependency> </dependencies>
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.