Google Cloud VM 上的 Akka 远程处理

标签 akka google-cloud-platform akka-remote-actor

我是 Akka 新手,我正在尝试运行一个简单的远程 Actor,该 Actor 在 Google Cloud VM 实例上的本地主机上运行。

虚拟机具有内部和外部 IP。当我启动一个 IP 设置为外部的 Actor 时,它无法启动。

但是当我这样做的时候

netty.tcp {
  hostname = "<internal IP>"
  port = 45000

一切都开始得很顺利。

现在显然,当尝试从另一台机器连接时,内部 IP 无法解析,因此我尝试使用以下命令查找参与者:

context.actorSelection("akka.tcp://Main@<external IP>:45000/user/app")

并出现以下错误:

[错误] 为非本地收件人 [Actor[akka.tcp://Main@外部 IP:45000/]] 丢弃到达 [akka] 的消息 [class akka.actor.ActorSelectionMessage] .tcp://Main@外部IP:45000]入站地址为[akka.tcp://Main@内部IP:45000]

最后一部分确实有道理,但我如何使整个事情发挥作用?

最佳答案

找到解决方案。

它基于即将推出的 2.4 版本中提供的 bind-hostname 配置设置:

build.sbt

resolvers += "Typesafe Snapshots" at "http://repo.akka.io/snapshots/"

libraryDependencies ++= Seq(
  "com.typesafe.akka" %% "akka-actor" % "2.4-SNAPSHOT",
  "com.typesafe.akka" %% "akka-remote" % "2.4-SNAPSHOT"
)

application.conf

akka {
  actor {
    provider = "akka.remote.RemoteActorRefProvider"
  }
  remote {
    enabled-transports = ["akka.remote.netty.tcp"]
    netty.tcp {
      hostname = "external IP"
      port = 45000
      bind-hostname = "internal IP"
    }
 }
}

如果需要,您还可以指定bind-port

关于Google Cloud VM 上的 Akka 远程处理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31069678/

相关文章:

mysql - 无法从不同项目中的 firebase 云函数访问云 SQL

google-cloud-platform - 如何针对特定语言改进 Google Vision API 的 TEXT_DETECTION

java - Akka调度程序: Run next only when current run is complete

scala - Akka http 请求在通过管道传输给 actor 时不会被 runFold 使用

google-cloud-platform - 将镜像从 Docker 注册表移动到 GCR

java - 关闭远程 akka actor 连接?

java - Akka远程路由主机名配置问题

sockets - Akka 远程连接

scala - akka 调度器的延迟如何?

scala - 将 Source[ByteString, Future[IOResult]] 转换为 List[String]