I am building an akka service and for local testing purposes using akka-discovery in config mode. I discovered that when switching from defined seed nodes for the cluster creation to the discovery-mechanism (akka-discovery) my cluster singleton stops to work. On an ask I simply get a Timeout from the respective singleton (I am using the proposed mechanism of cummunicating to that singleton via a proxy). I could neither find a solution to that problem nor understand it currently since I create the SingletonManager instance on each node after having started the cluster bootstrap. Even when I include a wait of around a minute after the ClusterBootstrap start() call before creating the singleton manager I get the same result, where I would think such cluster functionality is already available since the cluster is up.
Rough code samples:
- Sbt:
"com.lightbend.akka.management" %% "akka-management-cluster-bootstrap" % "0.19.0", "com.lightbend.akka.management" %% "akka-management" % "0.19.0", "com.lightbend.akka.management" %% "akka-management-cluster-http" % "0.19.0", "com.lightbend.akka.discovery" %% "akka-discovery-config" % "0.19.0", "com.typesafe.akka" %% "akka-cluster" % "2.5.18", "com.typesafe.akka" %% "akka-cluster-metrics" % "2.5.18", "com.typesafe.akka" %% "akka-cluster-tools" % "2.5.18", "com.typesafe.akka" %% "akka-contrib" % "2.5.18", "io.kamon" % "sigar-loader" % "1.6.6-rev002", "org.scalactic" %% "scalactic" % "3.0.5", "com.typesafe.akka" %% "akka-stream-testkit" % "2.5.18" % Test, "org.scalatestplus.play" %% "scalatestplus-play" % "3.0.0" % "test"
- Cluster Node Start (code executed on all nodes):
val system = ActorSystem(applicationName, baseConfig) AkkaManagement(system).start() ClusterBootstrap(system).start() val clusterSingletonProperties = ClusterSingletonManager.props( singletonProps = SingletonActor.props, terminationMessage = PoisonPill, settings = ClusterSingletonManagerSettings.apply(singletonConfig) ) actorSystem.actorOf(clusterSingletonProperties, "singleton")
- controller call (I just sent the ask, in the singleton actor I , on any received string return another string without any processing):
val workerService: ActorRef = actorSystem.actorOf( ClusterSingletonProxy.props( singletonManagerPath = "/user/singleton", settings = ClusterSingletonProxySettings.create(singletonProxyConfig) ) ) (workerService ? "holla").mapTo[String].map { message => val result = Json.toJson({"result" -> message}) Ok(result) })
The above works when seed-nodes are defined, but not in discovery. The order by which I start the system, the bootstrap and the singleton manager to me suggests that there should be no cause of cluster service not yet being available, since cluster is up when creating the singleton manager.
Any suggestions out there?
Thanks, Best regards, Andi