Page History
...
그래서 익숙한 도트접근을 통해 로컬에서 개발되었다고 해도 그어떤 값도 얻어 낼수 없습니다.(메모리 공유를 원천 차단합니다.)
| OOP | ACTOR |
|---|---|
Lobby a; a.getTable(1).getTableName(); | LobbyActor a; TableActor b; b.tell("some ask",a) |
로컬에서 구현이 복잡해지는 단점이 있으나, 리모트로 확장시 구현의 차이가 없어진다는 장점이 있습니다.
주소를 통한 Ask패턴사용
| Code Block | ||||
|---|---|---|---|---|
| ||||
private ActorRef findTableByID(int tableID) throws Exception {
String tableActorPath = "/user/lobby/table-"+tableID;
ActorSelection tableSelect = this.getContext().actorSelection(tableActorPath);
FiniteDuration duration = FiniteDuration.create(1, TimeUnit.SECONDS);
Future<ActorRef> fut = tableSelect.resolveOne(duration);
ActorRef tableActor = Await.result(fut, duration);
return tableActor;
} |
...
멤버접근을 통한 정보 획득은 불가하며 로컬이라 할지라도 tell 로 질의를 해야합니다.
로컬에서의 개발시 메모리접근을 못한다는것은 아주 큰 제약이 될수 있으나, 리모트로 확장한다고 가정해봅시다.
리모트 컴퓨터의 메모리를 접근하려면 기존 개발코드를 다시 작성해야할것입니다. 이것은 리모트뿐만 아니라
단일노드 동시처리에서도 스레드모델에서 발생하는 Lock/Unlock의 복잡한 문제를 직접 코드로 구현할 필요가 없어진다란 점입니다.
주소선택을 통한 전송
| Code Block | ||||
|---|---|---|---|---|
| ||||
ActorSelection lobbyActor = system.ActorSelection("user/lobby");
lobbyActor.tell("some message",null);
// 자식의 모든 요소 선택이 가능합니다.
ActorSelection tableAllActor = system.ActorSelection("user/lobby/table/*");
tableAllActor.tell("some message",null); |
...