title: How to send an Akka actor shutdown message from controller in play framework
body: <p>I'm new to Akka but really liking the framework already.  I've looked through the <a href="http://doc.akka.io/docs/akka/2.2.1/scala/actors.html" rel="nofollow">Akka Actor documentation</a> and some of the Playframework / typesafe tutorials. I have successfully created an actor from a successful POST request in a controller by</p>
  
  <pre><code>val reapeter = Akka.system.actorOf(Props(classOf[RepeaterActor], data), name = "repeater")
  </code></pre>
  
  <p>that does a periodic task using a schedule task.</p>
  
  <p>Now I would like to send this actor a stop message from a GET/POST request in a controller. I have tried</p>
  
  <pre><code>def stop = Action {
      val sendStop = Akka.system.actorSelection("/user/repeater").tell(Shutdown, ActorRef.noSender)
  }
  </code></pre>
  
  <p>and in RepeaterActor's receieve method </p>
  
  <pre><code>receieve {
      ...
      case Shutdown =&gt; {
          println("shutting down")
          context.system.stop(self)
      }
  }
  </code></pre>
  
  <p>But I can't get a response.  I'm not sure if it's a problem with my actorSelection method or how I'm doing the message calls. How can I implement a simple shutdown hook for an actor callable from a controller?  For the time being there only needs to be one of these RepeaterActors.</p>