I가 다음과 같은 요구 사항동기화 AKKA 배우 가장 좋은 방법
나는 주요 작업을 완료해야
배우 A : 메시지가가 배우 B에 전달 '특별한'경우, 주요 작업을 수행합니다 처리 한 다음 작업 배우 B 완료 : 주요 작업에 대한 특별 논리적 인 작업을 수행하고 A와 B는 함께 이것을
구현
public static class ActorA extends UntypedActor {
public void onReceive(Object message) {
if (message instanceof Work) {
// if message is special
ActorRef actorB = this.getContext().actorOf(Props.create(ActorB.class,));
actorB.tell(new specialTask(message.property), getSelf());
} else {
unhandled(message);
}
}
}
를 완료
public static class ActorB extends UntypedActor {
public void onReceive(Object message) {
if (message instanceof specialTask) {
//do special task using the message that does not change the state of the message
} else {
unhandled(message);
}
}
}
이 ActorA는 배우 조식 작업의 완료를 의존하지 않는
배우 B. 그러나 배우 B가 완료되면 A와 B 사이를 지나가는 메시지가 없어야하는지 확실하지 않습니다. 이것이 올바른 접근 방법입니까?
작동 코드가 codeview.stackexchange.com에 – GhostCat
감사를 가야한다, http://codereview.stackexchange.com/questions/150871/synchronised-akka-actor-best-practice coderview.stackexchange 접수 –
문제의 밤은을 기록했다. co.kr에서 계속 노력하겠습니다. 감사합니다 –