Note that there are some explanatory texts on larger screens.

plurals
  1. POPlay framework 2.0 - deadLetters instead of an Actor
    primarykey
    data
    text
    <p>For learning purposes I'm trying to implement a simple play application that gets data from a remote actor. The code for the actor is as follows:</p> <pre><code>import akka.actor.{Props, ActorSystem, Actor} class NumbersServer extends Actor { var number = 0 protected def receive = { case 'next =&gt; { number += 1 number } case 'reset =&gt; number = 0 case 'exit =&gt; context.stop(self) case 'get =&gt; sender ! number } } object Server { def main(args: Array[String]) { val system = ActorSystem("ServerSystem") val server = system.actorOf(Props[NumbersServer], "server") } } </code></pre> <p>I package it into a jar and start it from the command line. If I try to send messages to this actor from a Scala console opened from another window, all works fine. Now I want to get the actor from the Play framework. In the <code>Application</code> object I define the following method:</p> <pre><code>def numbers = Action { Ok(views.html.numbers(Client.actor.path.name)) } </code></pre> <p>Then in the <code>models</code> package I define the Client object:</p> <pre><code>object Client { import play.api.Play.current val actor = Akka.system.actorFor("akka://ServerSystem@127.0.0.1:2552/user/server") } </code></pre> <p>The <code>numbers.html.scala</code> file:</p> <pre><code>@(message: String) @main("Header") { &lt;h1&gt;@message&lt;/h1&gt; } </code></pre> <p>So I expect that when I go to <code>127.0.0.1:9000/numbers</code>, I'd get a page with the path to the server actor. Instead of this, I get <code>&lt;h1&gt;deadLetters&lt;/h1&gt;</code>. What do I do wrong and how this should be done correctly?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload