I am trying to use a broadcast router in Scala, if I am not mistaken, it should look like this:
val system = ActorSystem("My beautiful system") val workerRouter = system.actorOf(Props[Agent].withRouter(BroadcastRouter(individualDefinitions.size)), name = "agentRouter")
This is what I understand from the tutorial that I am following .
A working router acts like another actor, and I can send messages to this router, which will send them to all Agents (as many as I have separate definitions).
The problem is that I would like to use separate definitions for assembling agents, they actually take some parameters in the constructor, and these parameters are in individual definitions.
Q: How can I tell the router to pass these parameters to each of them as part of the constructor?
Please note that each actor must receive one individual definition, and they are all different. I cannot use the solution in a related question where the constructor gets constants: In the Java actor model Akka, can a router create actors with a non-default constructor?
Please note that each actor must have different parameters, if one of them is restarted, he should get the same parameters that he received in the first place. I do not know if this solution can be changed for this.
A possible solution may be to use the actor as a router, to separate the creation (constructor) and routing, as in the question of Akka (java), without blocking for all children .
I am not sure if this is the βrightβ approach in this case. Using an actor because the router has several problems (besides elegance). Iβm worried about an actor who works like a router that restarts and loses all of his subscribers. If an actor restarts in half a cycle, some participants may also skip some messages if I am not mistaken.
Thanks.
constructor scala akka routing
Trylks
source share