Consul
This module is 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: Apache Pekko Discovery Consul | |
---|---|
Artifact | org.apache.pekko
pekko-discovery-consul
1.1.0
|
JDK versions | OpenJDK 8 OpenJDK 11 OpenJDK 17 OpenJDK 21 |
Scala versions | 2.12.20, 2.13.15, 3.3.4 |
License | |
Home page | https://pekko.apache.org/ |
API documentation | |
Forums | |
Release notes | Release Notes |
Issues | GitHub issues |
Sources | https://github.com/apache/pekko-management |
- sbt
val PekkoManagementVersion = "1.1.0" libraryDependencies += "org.apache.pekko" %% "pekko-discovery-consul" % PekkoManagementVersion
- Gradle
def versions = [ PekkoManagementVersion: "1.1.0", ScalaBinary: "2.13" ] dependencies { implementation "org.apache.pekko:pekko-discovery-consul_${versions.ScalaBinary}:${versions.PekkoManagementVersion}" }
- Maven
<properties> <pekko.management.version>1.1.0</pekko.management.version> <scala.binary.version>2.13</scala.binary.version> </properties> <dependencies> <dependency> <groupId>org.apache.pekko</groupId> <artifactId>pekko-discovery-consul_${scala.binary.version}</artifactId> <version>${pekko.management.version}</version> </dependency> </dependencies>
pekko-discovery-consul
can be used with Pekko 1.1.2 or later. You have to override the following Pekko dependencies by defining them explicitly in your build and define the Pekko version to the one that you are using. Latest patch version of Pekko is recommended and a later version than 1.1.2 can be used.
- sbt
val PekkoVersion = "1.1.2" libraryDependencies ++= Seq( "org.apache.pekko" %% "pekko-cluster" % PekkoVersion, "org.apache.pekko" %% "pekko-discovery" % PekkoVersion )
- Gradle
def versions = [ PekkoVersion: "1.1.2", ScalaBinary: "2.13" ] dependencies { implementation "org.apache.pekko:pekko-cluster_${versions.ScalaBinary}:${versions.PekkoVersion}" implementation "org.apache.pekko:pekko-discovery_${versions.ScalaBinary}:${versions.PekkoVersion}" }
- Maven
<properties> <pekko.version>1.1.2</pekko.version> <scala.binary.version>2.13</scala.binary.version> </properties> <dependencies> <dependency> <groupId>org.apache.pekko</groupId> <artifactId>pekko-cluster_${scala.binary.version}</artifactId> <version>${pekko.version}</version> </dependency> <dependency> <groupId>org.apache.pekko</groupId> <artifactId>pekko-discovery_${scala.binary.version}</artifactId> <version>${pekko.version}</version> </dependency> </dependencies>
In your application conf add:
pekko.discovery {
method = pekko-consul
pekko-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 pekko management is set up so that
# the seed nodes can be found, an example value for the tag would be `pekko-management-port:19999`
application-pekko-management-port-tag-prefix = "pekko-management-port:"
}
}
Notes:
-
Since tags in Consul services are simple strings, prefixes are necessary to ensure that proper values are read.
-
If Pekko management port tag is not found on service in Consul the implementation defaults to catalog service port.