I have some Akka project and I have the following scenario: I have plenty of actors for which I would like to have a human-readable name, but at the same time, I don't want to generate unique names for each one by myself. So, is there a way so I can tell to the props or the actor system to prefix the automatically-generated name with a specific string?
For example, I have some actor Master who creates some children of type Worker. I would like that the name of each children starts by "worker-" so I can follow easily in the logs. Also, if possible, I would like to know if there are other ways to name the actors in a more fine-grained fashion.
Thanks in advance.
EDIT: this is an example of what I would like to have
Currently, you have two options, a far as I can see:
1) Create the actor with the automatically generated name
ActorRef myActor = mySystem.actorOf(MyActor.props());
2) Create the actor with a user-specified name
ActorRef myActor = mySystem.actorOf( MyActor.props(), MyNamingAPI.getSomeNewName() );
1) is bad because in the logs I don't know who is who. 2) is bad because I have to write/use my own API and because if someone else uses my actor project as subsystem, he will have to be careful to not repeat the names or use a different actor system. So, it's not portable.
I would like if Akka supported something like:
ActorRef myActor = mySystem.actorOf(MyActor.props(), "my-actor-%");
where the % symbol denotes the automatically generated ID.
As @VinceEmigh mentioned in the comments, this is not supported by the API. Moreover, Akka team have no plans to support it any soon (or at all). More on this here.