In the Java acc-model, Akka can a router create actors with a constructor other than the standard?

In the Akka Java acting model, if I have a RoundRobinRouter when its tell() method is called, I want the router (as a wizard) to create child entities with a non-default constructor, because I need to pass some parameters, How can I do this to do?

I understand that I can have an actor with a non-default constructor using Props , but how is it used when the main actor is a router?

Thanks!

+2
actor akka default-constructor
source share
1 answer

The details in the construction of the router are the pillars for the routes of this router, and not the router itself.

You can just do something like:

 system.actorOf(new Props(new UntypedActorFactory() { public UntypedActor create() { return new MyActor("foo", "bar"); } }).withRouter(...)) 

And all routes will be of type MyActor with the specified constructor.

You can do anything with the help of props, which you usually can. See Akk Documents for more information.

+5
source share

All Articles