0

我对 Akka 很陌生,但到目前为止我真的很喜欢它。我已经能够在本地运行一个小型应用程序,现在我想测试远程部署和使用远程参与者。

为此,我查看并编译了 Java Akka 2.0.1 akka-remote-sample 示例,位于 ..

https://github.com/akka/akka/tree/master/akka-samples/akka-sample-remote

但是当我尝试运行编译的示例时..

java -classpath `pwd`/src/main/resources:target/akka-remote-1.1.jar sample.remote.calculator.java.JCalcApp 我收到有关 application.conf 的错误

我已经多次尝试调整示例 application.conf 文件,但最接近成功运行远程示例应用程序的是..

线程“main”中的异常 akka.remote.RemoteTransportException:无法加载远程传输层 akka.remote.netty.NettyRemoteTransport

我正在使用 Maven shade 插件将我的所有依赖项包含在 jar 中。这适用于本地应用程序。

有人可以看看我的conf文件,让我知道我需要改变什么。

谢谢你 !!

这是我的 application.conf 文件...

//#calculator
calculator {
include "common"

 akka {
    backoff-timeout = 0ms
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.netty.port = 2552
  }
}
//#calculator

//#remotelookup
remotelookup {
  include "common"

  akka {
    backoff-timeout = 0ms
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2553
  }
}
//#remotelookup

//#remotecreation
remotecreation {
  include "common"

  akka {
    actor {
      deployment {
        /advancedCalculator {
          remote = "akka://CalculatorApplication@127.0.0.1:2552"
        }
      }
    }
    backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2554
  }
}
//#remotecreation

和 common.conf ...

akka {

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

  remote {
    netty {
      hostname = "127.0.0.1"
    }
  }
} 
4

1 回答 1

0

好的,想通了。使用此 application.conf,远程示例将起作用。

注意:还要确保在类路径中包含 application.conf 的路径。

//#calculator
calculator {
  include "common"

  akka {
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.netty.port = 2552
  }
}
//#calculator

//#remotelookup
remotelookup {
  include "common"

  akka {
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.backoff-timeout = 0ms
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2553
  }
}
//#remotelookup

//#remotecreation
remotecreation {
  include "common"

  akka {
    actor {
      deployment {
        /advancedCalculator {
          remote = "akka://CalculatorApplication@127.0.0.1:2552"
        }
      }
    }
    remote.netty.max-total-memory-size = 0b
    remote.netty.max-channel-memory-size = 0b
    remote.netty.execution-pool-size = 4
    remote.netty.execution-pool-keepalive = 60s
    remote.netty.backlog = 4096
    remote.netty.connection-timeout = 120s
    remote.netty.outbound-local-address = "auto"
    remote.netty.message-frame-size = 1 MiB
    remote.netty.reconnect-delay = 5s
    remote.netty.all-timeout = 0s
    remote.netty.write-timeout = 0s
    remote.netty.read-timeout = 0s
    remote.netty.reconnection-time-window = 600s
    remote.netty.backoff-timeout = 0ms
    remote.netty.secure-cookie = ""
    remote.netty.require-cookie = off
    remote.netty.use-passive-connections = on
    remote.untrusted-mode = off
    remote.remote-daemon-ack-timeout = 30s
    remote.log-received-messages = on
    remote.log-sent-messages = on
    remote.transport = "akka.remote.netty.NettyRemoteTransport"
    remote.netty.port = 2554
  }
}
//#remotecreation
于 2012-04-24T18:29:43.077 回答