老版本的AKKA换成新版本会有
Exception in thread "main" java.lang.IllegalArgumentException: cannot use non-static local Creator to create actors; make it static (e.g. local to a static method) or top-level
new UntypedActorFactory() { public UntypedActor create() { return new ReduceActor(aggregateActor); } }
都是UntypedActorFactory造成的。新版已经不使用了。
可以改写成:
static class newCreator implements Creator<ReduceActor> { private static final long serialVersionUID = -1772539428749702579L; final ActorRef actorRef; public newCreator(ActorRef actorRef) { super(); this.actorRef = actorRef; } @Override public ReduceActor create() throws Exception { return new ReduceActor(actorRef); } }
这个是个例子,需要根据具体情况进行修改。