I’m using Akka to control access to running system processes.
I have a single CommandActor that handles incoming command requests from any actor in the system (lets call it the RequestActor), and for each new request the CommandActor spawns a separate CmdChildWorker actor to handle that particular request. The CommandActor also limits the number of CmdChildWorkers, and assigns a unique id to each request, so it is more complicated than a simple router.
When the command completes, and periodically during the execution of the system process, the CmdChildWorker actors sends periodic updates back to the original RequestActor (e.g. process output so far).
However, to maintain a clean design, I was hoping that I would be able to keep the CmdChildWorker completely hidden from the original RequestActor, with its only interface being to the single CommandActor.
Obviously, I could send any reply messages from the CmdChildWorker back via the CommandActor, but I was wondering if it is possible to reply back to the RequestActor directly from the CmdChildWorker without having to route the message via the CommandActor, but still pretending that the message has been sent back from the CommandActor.
I.e. I would like to spoof the CmdChildWorker actors senders address to be that of its parent actor. Is this possible? And perhaps more importantly is this sensible, or good actor design?
Thanks
See the
tellmethod on actor. When the CommandActor forwards its message, call:childActor.tell(msg, sender)and the childActor will have its sender as the original sender.