如何使用父actor上下文在java-akka中分配自定义调度程序?

时间:2017-05-25 07:14:33

标签: java akka

我使用akka在java中创建了一个actor系统,方法如下。我也创建了主管演员。

  

final ActorSystem system = getSystem();           system.actorOf(Props.create(Supervisor.class),Supervisor.NAME);

我按以下方式更新了默认调度程序。

akka {
      default-dispatcher {
        # Dispatcher is the name of the event-based dispatcher
        type = Dispatcher
        # What kind of ExecutionService to use
        executor = "fork-join-executor"
        # Configuration for the fork join pool
        fork-join-executor {
          # Min number of threads to cap factor-based parallelism number to
          parallelism-min = 256
          # Parallelism (threads) ... ceil(available processors * factor)
          parallelism-factor = 40.0
          # Max number of threads to cap factor-based parallelism number to
          parallelism-max = 512
        }
        # Throughput defines the maximum number of messages to be
        # processed per actor before the thread jumps to the next actor.
        # Set to 1 for as fair as possible.
        throughput = 1
      }
}

我面临的问题是我为特定演员编写自定义调度程序。因为它无法识别演员的模式

1 个答案:

答案 0 :(得分:0)

您需要添加"部署"部分到您的配置。

代码:

ActorRef myActor =
  system.actorOf(Props.create(MyActor.class),
    "myactor");

配置:

akka.actor.deployment {
  /myactor {
    dispatcher = my-dispatcher
  }
}

查看the documentation