I'm just starting Akka and I'm trying to understand the difference between actor pools and groups and when to use which. In the doc it briefly says that a group is not created by a router, so that means they don't have a master?
In the situation below, can you route messages directly from one worker group (or pool?) to another without sending it via the Master?
About the difference:
Sometimes, rather than having the router actor create its routees, it is desirable to create routees separately and provide them to the router for its use. You can do this by passing an paths of the routees to the router's configuration. Messages will be sent with ActorSelection to these paths.
So the difference is that in case of "pool", your workers are created (and supervized) automatically by the pool. In case of "group" - you have to first create actors and then pass a list of paths (which will be used in ActorSelection
) to these actors into the master:
val router: ActorRef = // group's master, but not supervisor
context.actorOf(RoundRobinGroup(List("/user/workers/w1", "/user/workers/w2", "/user/workers/w3")).props(), "router4")
So, both have a master actor (router
), but in second case workers are created manually by another actor(s) - so this another actor supervise them by default (if they are not top-level, of course) and receiving lifecycle messages. As a result you have 3 kinds of actors here: master, supervisor(s), workers.
About the "direct" routing. Every group/pool has its own synthetic master actor, so when you sending a message to the group, it's always going to the master first. But, if you know the address of the group member (like "/user/workers/w1" in example above), nothing stops you from sending message directly to the worker.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With