2

我想将 Akka 配置为使用带有 redis 持久邮箱的远程参与者,如下所示。

common.conf 文件:

 akka {
     actor {
         mailbox {
             redis {
                hostname = "127.0.0.1"
                port = 6379
              }
         }
     provider = "akka.remote.RemoteActorRefProvider"   }

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

和我的 application.conf 文件:

calculatorActor {include "common"}
remotecreation {
include "common"
akka {
    actor {
      deployment {
        /advancedCalculator {
          router = "round-robin"
          nr-of-instances = 200
          target {
            nodes = ["akka://CalculatorApplication@127.0.0.1:2552"]
          }

        }
      }
    }
    remote.netty.port = 2554
  }
}

这是从 akka-sample-remote 派生的配置。当我运行应用程序时,我看不到任何与 redis 端(持久邮箱!)的连接。Redis 日志仅包含:

0 clients connected (0 slaves)
4

1 回答 1

5

您必须指定具有正确邮箱类型的调度程序。

来自文档:

my-dispatcher {
  mailbox-type = akka.actor.mailbox.RedisBasedMailboxType
}

然后使用此调度程序创建您的演员:

val myActor = system.actorOf(Props[MyActor].withDispatcher("my-dispatcher"), name = "myactor")
于 2012-04-12T14:23:36.290 回答