Package akka.actor.typed.scaladsl
Class Routers
- java.lang.Object
-
- akka.actor.typed.scaladsl.Routers
-
public class Routers extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description Routers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> GroupRouter<T>
group(ServiceKey<T> key)
A router that will keep track of the available routees registered to theReceptionist
and route over those by random selection.static <T> PoolRouter<T>
pool(int poolSize, Behavior<T> behavior)
SpawnpoolSize
children with the givenbehavior
and forward messages to them using round robin.
-
-
-
Method Detail
-
group
public static <T> GroupRouter<T> group(ServiceKey<T> key)
A router that will keep track of the available routees registered to theReceptionist
and route over those by random selection.In a clustered app this means the routees could live on any node in the cluster. The current impl does not try to avoid sending messages to unreachable cluster nodes.
Note that there is a delay between a routee stopping and this being detected by the receptionist and another before the group detects this. Because of this it is best to deregister routees from the receptionist and not stop until the deregistration is complete if you want to minimize the risk of lost messages.
-
pool
public static <T> PoolRouter<T> pool(int poolSize, Behavior<T> behavior)
SpawnpoolSize
children with the givenbehavior
and forward messages to them using round robin. If a child is stopped it is removed from the pool. To have children restart on failure, use supervision. When all children are stopped the pool stops itself. To stop the pool from the outside, useActorContext.stop
from the parent actor.Note that if a child stops, there is a slight chance that messages still get delivered to it, and get lost, before the pool sees that the child stopped. Therefore it is best to _not_ stop children arbitrarily.
-
-