在本地演员

时间:2015-06-23 21:31:56

标签: scala akka typesafe-stack akka-remote-actor

我正在学习akka-remote并尝试自己重新http://www.typesafe.com/activator/template/akka-sample-remote-scala

当我尝试在两个独立的JVM中运行项目时,我看到了

$ clear;java -jar akkaio-remote/target/akka-remote-jar-with-dependencies.jar com.harit.akkaio.remote.RemoteApp ProcessingActor

ProcessingActorSystem Started

$ clear;java -jar akkaio-remote/target/akka-remote-jar-with-dependencies.jar com.harit.akkaio.remote.RemoteApp WatchingActor

WatchingActorSystem Started
asking processor to process
processing big things

我让我的Processing System在端口2552上运行

include "common"
akka {
  # LISTEN on tcp port 2552
  remote.netty.tcp.port = 2552
}

我告诉我的其他系统(WatchingSystem)在端口2554上运行,但在端口processingActor上启动2552

include "common"

akka {
  actor {
    deployment {
      "/processingActor/*" {
        remote = "akka.tcp://ProcessingActorSystem@127.0.0.1:2552"
      }
    }
  }
  remote.netty.tcp.port = 2554
}

common是关于使用正确的提供商

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

  remote {
    netty.tcp {
      hostname = "127.0.0.1"
    }
  }
}

问题/疑虑

  1. 从日志中,我发现processingActor正在WatchingActorSystem而非ProcessingActorSystem上运行,出现了什么问题?
  2. 我如何看到两个ActorSystems相互连接。我没有看到日志记录发生。但是,在示例中,我共享了日志记录。我错过了什么?
  3. 整个代码发布在Github上并且也会运行

1 个答案:

答案 0 :(得分:0)

1)您的部署配置设置为使processingActor的所有子节点都是远程的,如akka configuration docs

中所述

您应该将其设置为:

deployment {
  "/processingActor" {
    remote = "akka.tcp://ProcessingActorSystem@127.0.0.1:2552"
  }

2)您需要将日志级别设置为有用的内容,如akka logging documentation

中所述