Note that there are some explanatory texts on larger screens.

plurals
  1. POAkka remote actors cannot communicate between Play! applications
    text
    copied!<p>I am testing usage of Akka remote actors between two Play! v2.1-RC4 applications.</p> <p>Here is my code from App1</p> <pre><code>override def onStart( app: Application ) { val system = ActorSystem("App1System", ConfigFactory.load.getConfig("app1")) val remoteActor = Akka.system().actorFor("akka://App2System@127.0.0.1:9003/user/app2Actor") println(s"remote actor : ${remoteActor.path}") val jobsActor = Akka.system.actorOf(Props(new Actor { def receive = { case "Job1" =&gt; { println("\nsending Job #1 at regular intervals to App2\n"); remoteActor ! "Job1" } case "Job2" =&gt; { println("\n... sending doing job #2, 7 seconds after start, only once\n"); remoteActor ! "Job2" } } }), "app1Actor") // Repeat every 5 seconds, start 5 seconds after start Akka.system.scheduler.schedule( 5 seconds, 5 seconds, jobsActor, "Job1" ) // do only once, 7 seconds after start Akka.system.scheduler.scheduleOnce(7 seconds, jobsActor, "Job2") } </code></pre> <p>here is the config file of App1:</p> <pre><code> akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { transport = "akka.remote.netty.NettyRemoteTransport" netty { hostname = "127.0.0.1" port = 9002 } } } app1 { include "common" } </code></pre> <p>Code from App2 : </p> <pre><code> override def onStart( app: Application ) { val system = ActorSystem("App2System", ConfigFactory.load.getConfig("app2")) val app2Actor = Akka.system.actorOf(Props(new Actor { def receive = { case "Job1" =&gt; println("App 2: doing Job #1 at regular intervals") case "Job2" =&gt; println("App 2: ... doing job #2, 7 seconds after start, only once") case _ =&gt; println("App 2 recieved other message") } }), "app2Actor") println(s"app 2 actor : ${app2Actor.path}") } </code></pre> <p>Config from App2 : </p> <pre><code>akka { actor { provider = "akka.remote.RemoteActorRefProvider" } remote { transport = "akka.remote.netty.NettyRemoteTransport" netty { hostname = "127.0.0.1" port = 9003 } } } app2 { include "common" } </code></pre> <p>I have followed the instructions from the link <a href="http://doc.akka.io/docs/akka/2.1.0/scala/remoting.html#remote-lookup-sample-scala" rel="nofollow">Akka - Remoting</a></p> <p>My console output from App1 :</p> <pre><code>[info] application - Application started [INFO] [02/06/2013 21:56:49.570] [New I/O worker #1] [NettyRemoteTransport(akka://application@127.0.0.1:9002)] RemoteServerStarted@akka://application@127.0.0.1:9002 [info] play - Starting application default Akka system. remote actor : akka://App2System@127.0.0.1:9003/user/app2Actor [info] play - Application started (Dev) sending Job #1 at regular intervals to App2 [INFO] [02/06/2013 21:56:54.918] [application-akka.actor.default-dispatcher-5] [NettyRemoteTransport(akka://application@127.0.0.1:9002)] RemoteClientStarted@akka://App2System@127.0.0.1:9003 ... sending doing job #2, 7 seconds after start, only once sending Job #1 at regular intervalsto App2 sending Job #1 at regular intervalsto App2 sending Job #1 at regular intervalsto App2 [info] application - Application stopped [info] play - Shutdown application default Akka system. [INFO] [02/06/2013 21:57:10.619] [application-akka.actor.default-dispatcher-16] [NettyRemoteTransport(akka://application@127.0.0.1:9002)] RemoteClientShutdown@akka://App2System@127.0.0.1:9003 [INFO] [02/06/2013 21:57:10.635] [application-akka.actor.default-dispatcher-16] [NettyRemoteTransport(akka://application@127.0.0.1:9002)] RemoteServerShutdown@akka://application@127.0.0.1:9002 </code></pre> <p>My console output from App2 :</p> <pre><code>[info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9001 (Server started, use Ctrl+D to stop and go back to the console...) [info] Compiling 6 Scala sources and 1 Java source to /home/rudy/development/projects/Actor/target/scala-2.10/classes... [info] application - Actor Application started [INFO] [02/06/2013 21:50:41.899] [New I/O worker #1] [NettyRemoteTransport(akka://application@127.0.0.1:9003)] RemoteServerStarted@akka://application@127.0.0.1:9003 [info] play - Starting application default Akka system. app 2 actor : akka://application/user/app2Actor [info] play - Application started (Dev) [INFO] [02/06/2013 21:56:54.961] [application-10] [NettyRemoteTransport(akka://application@127.0.0.1:9003)] RemoteClientStarted@akka://application@127.0.0.1:9002 [INFO] [02/06/2013 21:57:10.626] [application-7] [NettyRemoteTransport(akka://application@127.0.0.1:9003)] RemoteClientShutdown@akka://application@127.0.0.1:9002 </code></pre> <p>I can see that App1 is able to find the App2 Actor on the path (no DeadLetter), but none of the messages I expect to see on App2 console are appearing. </p> <p>Not sure where I am going wrong here. </p>
 

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