3
votes

I've set up one Akka.Net node to be the seed node in a cluster,which I call frontend, and another node which I call backend. In the frontend node I configure a cluster router group in code which makes it possible for me to send messages from the frontend to any nodes joining with the role 'backend' (in a round robin fashion) and that have an actor at /user/backend. The code that I have that is working looks like this:

system.ActorOf(Props.Empty.WithRouter(
    new ClusterRouterGroup(
        new RoundRobinGroup("/user/backend"),
        new ClusterRouterGroupSettings(10, false, "backend", ImmutableHashSet.Create("/user/backend"))
)));

Now I want to move this configuration to the config file instead (hocon). How would I go about doing that so that I only need the following code to instantiate it?

system.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "backend");

My attempt has only yielded exceptions with no clues.

/backend {
  router = round-robin-group
  routees.paths = ["/user/backend"]
  cluster {
    enabled = on
    max-nr-of-instances-per-node = 1
    allow-local-routees = off
    use-role = backend
  }
}

Any good hints? The only information I'm getting in the exception is:

Configuration problem while creating [akka://ClusterSystem/user/backend] with router dispatcher [akka.actor.default-dispatcher] and mailbox  and routee dispatcher [akka.actor.default-dispatcher] and mailbox [].
1
can you paste your whole HOCON section?AndrewS

1 Answers

4
votes

It's hard to say without seeing the full HOCON config. Seems like you just want a cluster-aware group router. Nothing obvious jumps out at me, but here are a few things that come to mind where I'd start looking:

  1. Have you specified your seed node? The frontend needs itself as a seed node too. It will "join itself" to start the cluster.
  2. Double check that you have all the necessary elements for Akka.Cluster in HOCON, including specifying the akka.cluster and akka.remote HOCON sections.
  3. Is the config for /backend inside the proper HOCON section? Needs to be in akka.actor.deployment.
  4. You don't need the max-nr-of-instances-per-node flag for a Group router. That's for pool routers to limit how many routees they deploy onto a given node in the cluster.

Here is a sample config that should work for the frontend node, based on what I can see. But it'd be helpful if you can add your full HOCON.

akka {
    actor {
        provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
        deployment {
            /backend {
                router = broadcast-group
                routees.paths = ["/user/backend"]
                cluster {
                  enabled = on
                  allow-local-routees = on
                  use-role = backend
                  }
                }
        }
    }

    remote {
        log-remote-lifecycle-events = DEBUG
        helios.tcp {
          hostname = "127.0.0.1"
          port = 0
        }
    }

    cluster {
      seed-nodes = ["akka.tcp://[email protected]:1234"] # specify your full frontend seed node address here
      roles = ["frontend"]
      auto-down-unreachable-after = 30s
    }
}