Hi,
I am confused how .withRouter(new SmallestMailboxPool(size))
works.
I am looking at some code where the actor is spawned like so -
system.actorOf(ActorA.props(5), "ActorA")
within the ActorA
class
public ActorA() {
log.info("created")
}
public static Props props(int poolSize) {
return Props.create(ActorA.class, () -> new actorA())
.withRouter(new SmallestMailboxPool(poolsize)).withDispatcher("custom_dispatcher");
}
According to the documentation, new SmallestMailboxPool(poolSize)
is a way of routing the messages to other actors. However in this code snippet I have shared above, there are no routees being spawned in the constructor, so what is the use of .withRouter()
here? I noticed that the log statement inside the constructor gets logged the number of times as poolsize. So does .withRouter(new SmallestMailboxPool(poolsize))
create the routees as well? Because if something inside the constructor is getting logged, I would assume it means that multiple instances are being created.
Confused about this…