我正在使用Akka打字,而且我无法查看官方文档(https://doc.akka.io/docs/akka/current/typed/actors.html#actors),我发现它非常简短,如何在Actor类型中配置Dispatcher。
这是我的代码示例
private int actorTimeout = Integer.parseInt(getProperty("environment.actor.timeout", "10"));
@Autowired
private AkkaTypedDAO akkaTypedDAO;
private ActorSystem<AkkaTypedDTO> system;
@PostConstruct
private void initActor() {
system = ActorSystem.create(akkaTypedDAO.daoWithSupervisor, "AkkaTypedDAO");
}
private final Behavior<CommandAkkaTyped> service = Actor.immutable((ctx, msg) -> {
sendToDAO(msg.id).thenApply(either -> {
msg.replyTo.tell(either);
return either;
});
return Actor.same();
});
public final Behavior<CommandAkkaTyped> serviceWithSupervisor = Actor.supervise(service).onFailure(Exception.class, restart());
private CompletionStage<Either<ConnectorErrorVO, EntityDaoDTO>> sendToDAO(MUSIn<AkkaTypedPayLoad> id) {
return AskPattern.ask(system,
(ActorRef<Either<ConnectorErrorVO, EntityDaoDTO>> replyTo) -> new AkkaTypedDTO(new EntityDaoDTO(musIn), replyTo),
new Timeout(actorTimeout, TimeUnit.SECONDS), system.scheduler());
}
当我创建ActorSystem时,如何为Actor.immutable配置调度程序?
答案 0 :(得分:2)
您正在使用过时的Akka Typed版本(有关Akka Typed API历史的更多信息,请参见here)。从Akka Typed documentation的当前版本开始(截至撰写本文时为2.5.14):
要在生成actor时指定调度程序,请使用DispatcherSelector。如果未指定,则actor将使用默认的调度程序,有关详细信息,请参见Default dispatcher。
course.teacher_id