Akkov deleted actors cannot communicate between Play! Applications

I am testing using Akka Remote Participants between two Games! v2.1-RC4.

Here is my code from App1

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" => { println("\nsending Job #1 at regular intervals to App2\n"); remoteActor ! "Job1" } 
    case "Job2" => { 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")
}

      

here is the App1 config file:

 akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 9002
    }
  }
}

app1 {
  include "common"
}

      

Code from App2:

    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" => println("App 2: doing Job #1 at regular intervals")
        case "Job2" => println("App 2: ... doing job #2, 7 seconds after start, only once")
        case _ => println("App 2 recieved other message")
      }
    }), "app2Actor")

    println(s"app 2 actor : ${app2Actor.path}")

  }

      

Configuration from App2:

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }

  remote {
  transport = "akka.remote.netty.NettyRemoteTransport"
    netty {
      hostname = "127.0.0.1"
      port = 9003
    }
  }
}

app2 {
  include "common"
}

      

I followed the instructions at Akka - Remoting link

My console output from App1:

[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

      

My console output from App2:

[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

      

I can see that App1 can find App2 Actor in the path (no DeadLetter), but none of the messages I expect to see on the App2 console appear.

Don't know where I went wrong here.

+3


source to share


1 answer


Akka.system

is an acting system provided by Play and you confused it with your current systems. Try to use only your own acting systems i.e. Change your code to:



val remoteActor = system.actorFor
val jobsActor = system.actorOf
system.scheduler.schedule

val app2Actor = system.actorOf

      

+3


source







All Articles