concept group in category akka

appears as: group, groups, group
Reactive Applications with Akka .NET

This is an excerpt from Manning's book Reactive Applications with Akka .NET.

  • Passing a poison pill message—Akka.NET provides a number of messages that can be sent to actors and processed before reaching the internals of your actor. One example of this is the poison pill message that’s identified by the PoisonPill class. The actor processes any messages in its mailbox until it reaches the poison pill message, which shuts down the actor before it processes any messages that arrived in the queue after the poison pill. With the PoisonPill, you can send messages to a single actor or a group of actors as you would send any other messages.
  • 7.2.2. Pools and groups

    In the last section, when you were deploying a broadcast router, you saw different terminology used: rather than a BroadcastRouter, you created an instance of a BroadcastPool. The reason for this is that Akka.NET supports two different types of routers: pools and groups. Although they both use the same logic to route messages to their routees, they differ in the way that routees are managed.

    Akka in Action

    This is an excerpt from Manning's book Akka in Action.

    The dynamic membership is more flexible and makes it possible for a group of nodes to grow and shrink as required. It enables dealing with failed nodes in the network, possibly automatically replacing them. It’s also far more complex than the static membership. When a dynamic membership is properly implemented, it needs to provide a mechanism to dynamically join and leave the group, detect and deal with network failures, identify unreachable/failed nodes in the network, and provide some kind of discovery mechanism through which new nodes can find an existing group on the network, since the network addresses aren’t statically defined.

  • Group— The group routers don’t manage the routees. The routees have to be created by the system and the group router will use the actor selection to find the routees. Group routers also don’t watch routees. All the routee management has to be implemented somewhere else within the system. A group can be used when you need to control the routees’ lifecycles in a special way or want to have more control over where the routees are instantiated (on which instances).
  • In figure 9.3 we show the actor hierarchy of the routees and see the difference between using a pool and the group router. The routees are children of the router, and when using the group, the routees can be a child of any other actor (in this example, the RouteeCreator). The routees don’t need to have the same parent. They just need to be up and running.

    Figure 9.3. Actor hierarchies of pool and group routers

    Akka has several built-in routers, summarized in table 9.1. This table shows the router logic and the associated pool and group that use the logic.

    Creating groups

    Creating a group is almost the same as creating a pool. The only difference is that a pool needs the number of routee instances, and a group needs a list of routee paths. Let’s start with creating the routees. You don’t need to do anything special, but in our example we want one parent Actor for all our GetLicense actors. We’ll introduce a GetLicenseCreator, which is responsible for creating the GetLicense actors. This actor will be used later to create new routees when one terminates.

    As you can see, the configuration barely differs from the pool configuration; nr-of-instances is replaced by routees.paths. Creating a group is even easier than creating a pool, because you don’t need to specify how the routees are to be created. And because a group uses actor paths, adding remote actors doesn’t need any changes. Just add the full path of the remote actor:

    akka.actor.deployment {
      /groupRouter {
        router = round-robin-group
    
        routees.paths = [
          "akka.tcp://AkkaSystemName@10.0.0.1:2552/user/Creator/GetLicense0",
          "akka.tcp://AkkaSystemName@10.0.0.2:2552/user/Creator/GetLicense0"]
      }
    }

    Configuring a group with the code is again easy; you only have to supply a list of the routee paths.

    Listing 9.8. Creating a group router with code
    val paths = List("/user/Creator/GetLicense0", "/user/Creator/GetLicense1") val router = system.actorOf( RoundRobinGroup(paths).props(), "groupRouter")