[英]Akka Java OneForOneStrategy example not compiling
I'm trying to paste the OneForOneStrategy into a simple Hello-Akka program, like so based on this documentation: http://doc.akka.io/docs/akka/2.3.2/java/fault-tolerance.html 我正在尝试将OneForOneStrategy粘贴到一个简单的Hello-Akka程序中,就像基于这个文档一样: http ://doc.akka.io/docs/akka/2.3.2/java/fault-tolerance.html
private static SupervisorStrategy strategy = new OneForOneStrategy(10,
Duration.create("1 minute"),
new Function<Throwable, SupervisorStrategy.Directive>() {
@Override
public SupervisorStrategy.Directive apply(Throwable t) {
if (t instanceof ArithmeticException) {
return resume();
} else if (t instanceof NullPointerException) {
return restart();
} else if (t instanceof IllegalArgumentException) {
return stop();
} else {
return escalate();
}
}
}
);
@Override
public SupervisorStrategy supervisorStrategy() {
return strategy;
}
However, the resume/restart/stop/escalate method calls don't compile out of the box. 但是,resume / restart / stop / escalate方法调用不会立即编译。 Why not?
为什么不?
Just add import listed below: 只需添加下面列出的导入:
import static akka.actor.SupervisorStrategy.escalate;
import static akka.actor.SupervisorStrategy.restart;
import static akka.actor.SupervisorStrategy.resume;
import static akka.actor.SupervisorStrategy.stop;
I've resolved this issue. 我已经解决了这个问题。 You just need to return SupervisorStrategy.resume(), SupervisorStrategy.restart() ... etc.
你只需要返回SupervisorStrategy.resume(),SupervisorStrategy.restart()......等等。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.