Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...


액터는 상대경로로 접근이 가능하며, 원격일경우 원격주소를 명시하여 원격접근도 가능합니다.


Querying the Logical Actor Hierarchy

No Format
Context.ActorSelection("../*").Tell(msg);

특정 트리뎁스의 액터를 모두 선택하여, 동일 메시지를 여러액터에게 보낼수 있습니다.



Reusing Actor Paths


Code Block
languagec#
themeEmacs
//동일한 주소의 액터를 생성하고 ,삭제하고 다시 생성한다.
IActorRef myActor = this.Sys.ActorOf<MyActor>("myActor");
ActorSelection myActor3 = this.Sys.ActorSelection("user/myActor");
myActor.GracefulStop(TimeSpan.FromSeconds(1)).Wait();
IActorRef myActor2 = this.Sys.ActorOf<MyActor>("myActor");

//주소 참조는, 동일한 주소에 액터가 있으면 참조가능하다.
myActor3.Tell("Hello", this.TestActor);
ExpectMsg("RE:Hello", TimeSpan.FromSeconds(0.2));

//액터 참조의경우 액터가 삭제되면 참조를 잃는다.
myActor.Tell("Hello", this.TestActor);
ExpectMsg("RE:Hello", TimeSpan.FromSeconds(0.2));

...

  • ActorRef : 참조이후 액터가 삭제되고, 다시 생성해도 이전에 참조된 액터의 참조이기때문에 참조를 잃게됩니다.
  • ActorSelection : 액터를 삭제/생성을 반복해도 액터주소에 대한 선택이기때문에 해당 경로에 액터가 존재하는한 접근가능합니다.

Actor Life Cycle

...


Top-Level Scopes for Actor Paths

  • "/user" is the guardian actor for all user-created top-level actors; actors created using ActorSystem.ActorOf are found below this one.
  • "/system" is the guardian actor for all system-created top-level actors, e.g. logging listeners or actors automatically deployed by configuration at the start of the actor system.
  • "/deadLetters" is the dead letter actor, which is where all messages sent to stopped or non-existing actors are re-routed (on a best-effort basis: messages may be lost even within the local CLR).
  • "/temp" is the guardian for all short-lived system-created actors, e.g. those which are used in the implementation of ActorRef.ask.
  • "/remote" is an artificial path below which all actors reside whose supervisors are remote actor references The need to structure the name space for actors like this arises from a central and very simple design goal: everything in the hierarchy is an actor, and all actors function in the same way. Hence you can not only look up the actors you created, you can also look up the system guardian and send it a message (which it will dutifully discard in this case). This powerful principle means that there are no quirks to remember, it makes the whole system more uniform and consistent.