In Akka Java actor model, if I have a RoundRobinRouter, when its tell()
method is called, I want the router (as the master) to create children actors with non-default constructor because I need to pass in some parameters. How can I do this?
I understand that I can an actor with non-default constructor using Props
, but how is it used when the master actor is a router?
Thanks!
The props in the construction of a Router is the props for the routees of that router, not the router itself.
You could simply do something like:
And all the routees will be of type MyActor with the specific constructor called.
You can do anything with the Props that you normally can. For more information see The Akka Docs