title: Akka Actors and Message Handling
body: <p>I have an ActorSystem where I create one top level actor and in this top level actor, I create a couple of child actors. So far good!</p>
  
  <p>What I then do is to expose these child actors to my Application controller (in a Play application) so that I can directly pipe the messages intended for the corresponding child actor from my Play controller. Is this a good practice or should I always pipe the messages to the child actor via the supervisor? In code, it would look like below:</p>
  
  <pre><code>class Application extends Controller with MyActors {
  
    def createUser = { request =&gt;
      val user: User = ... get the User from the request body
      userActor ! user
    }
  }
  </code></pre>
  
  <p>Here is what my Supervisor Actor looks like and it is controlled by the Play applications lifecycle plugin:</p>
  
  <pre><code>class SupervisorActor extends Actor with ActorLogging {
  
    val allActors = MyActors(context.system.settings.config, context)
  
    context watch allActors.userActor
  
    // TODO: what should we do in this SupervisorActor?
    def receive = {
      case Terminated(terminate) =&gt; context stop self
      case _ =&gt;
    }
  }
  </code></pre>
  
  <p>I then inject this MyActors into the Play Application controller. So my question, is this a good approach? The child actors are receiving messages directly from the outside world, without the messages having to go through the Supervisor actor. Is this a good approach. What problems could I face with this approach?</p>