[英]How to assign custom dispatcher in java-akka using parent actor context?
我以以下方式使用akka在Java中创建了一个actor系统。 我也创建了监督演员。
最终的ActorSystem系统= 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
}
}
我面临的问题是当我为特定角色编写自定义调度程序时。 因为它无法识别演员的模式
您需要在配置中添加“部署”部分。
码:
ActorRef myActor =
system.actorOf(Props.create(MyActor.class),
"myactor");
配置:
akka.actor.deployment {
/myactor {
dispatcher = my-dispatcher
}
}
查看文档
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.