0
我在阅读Akka文档,现在我在关于UntypedActors的部分。我决定尝试一些例子:了解Akka的主管策略
这里是我的演员:
家长
private static class MyUntypedActor extends UntypedActor{
public void onReceive(Object message) throws Exception {
System.out.println("Recieved: " + message);
}
@Override
public void preStart(){
getContext().actorOf(AnotherUntypedActor.props()).tell("Process it", getSelf());
}
public static Props props(){
return Props.create(MyUntypedActor.class);
}
}
儿童
private static class AnotherUntypedActor extends UntypedActor{
public static Props props(){
return Props.create(AnotherUntypedActor.class);
}
public void onReceive(Object message) throws Exception {
System.out.println("My: " + message);
throw new RuntimeException("Crashed: " + getSelf());
}
}
主:
public static void main(String[] args) throws TimeoutException {
ActorSystem system = ActorSystem.create();
Inbox inbox = Inbox.create(system);
ActorRef actorRef = system.actorOf(MyUntypedActor.props());
inbox.send(actorRef, "Message");
}
所以,我的小演员经历过失败和我应该它应该以某种方式通知父母。
但我收到的是:
Recieved: Message
My: Process it
[ERROR] [07/14/2016 19:05:13.726] [default-akka.actor.default-dispatcher-4] [akka://default/user/$a/$a] Crashed: Actor[akka://default/user/$a/$a#-950392568]
是什么监管实际上呢?儿童演员有过错,什么?我在日志中收到了一条错误消息。 supervisorStrategy是什么意思?它默认设置为
OneForOneStrategy(-1,Duration.Inf,true)
因此,策略的主要目的是定义一种如果异常抛出时如何反应的方式。实际决策是在决策功能中做出的。默认情况下,它什么也不做(就我所知),对吧? – user3663882
非常。据我记得,默认是'重新启动'。 –