Page History
...
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var manager = system.ActorOf<Manager>(); try { await manager.GracefulStop(TimeSpan.FromMilliseconds(5), "shutdown"); // the actor has been stopped } catch (TaskCanceledException) { // the actor wasn't stopped within 5 seconds } ... public class Manager : UntypedActor { private IActorRef worker = Context.Watch(Context.ActorOf<Cruncher>("worker")); protected override void OnReceive(object message) { switch (messageusing Akka.Actor; using Akka.TestKit; using AkkaDotModule.ActorSample; using AkkaNetCoreTest; using System; using System.Threading.Tasks; using Xunit; using Xunit.Abstractions; namespace TestAkkaDotModule.TestActors { public class HelloActor2 : ReceiveActor { private string MyName { get; set; } private IActorRef target = null; public HelloActor2(string name) { MyName = name; ReceiveAsync<string>(async message => { string inComeMessage = $"[{MyName}] : {message}"; }); } } public class TestManager : UntypedActor { IActorRef probe; private IActorRef worker = Context.Watch(Context.ActorOf( Props.Create(() => new HelloActor2("hello")), "worker" )); public TestManager(IActorRef _probe) { probe = _probe; } protected override void OnReceive(object message) { switch (message) { case "hello": worker.Tell("hello"); break; case "shutdown": worker.Tell(PoisonPill.Instance, Self); Context.Become(ShuttingDown); //종료모드로 메시지처리 상태변경 break; } } private void ShuttingDown(object message) { switch (message) { case "hello": //어떤 잡을 시키려고 할시,셧다운중임을 알립니다. Sender.Tell("service unavailable, shutting down", Self); break; case Terminated t: probe.Tell("SafeClose"); Context.Stop(Self); break; } } } public class LifeCycleActorTest : TestKitXunit { protected TestProbe probe; protected IActorRef manager; public LifeCycleActorTest(ITestOutputHelper output) : base(output) { case "job": Setup(); } public void worker.Tell("crunch");Setup() { break; //테스트 관찰자.. case Shutdown s: probe = this.CreateTestProbe(); worker.Tell(PoisonPill.Instance, Self); //하위GraceFulDown을 worker의위한 작동을Manager액터 중지시킵니다.생성 manager = Sys.ActorOf(Props.Create(() => new Context.Become(ShuttingDownTestManager(probe))); break; } }[Theory(DisplayName = "GracefulStopTest")] } [InlineData(5)] public privateasync voidTask ShuttingDownGtaceFulStopAreOK(objectint messagewaitTimeSec) { { switch (message) { //Step: case "job": //어떤 잡을1.GracefulStop 시키려고을통한 할시,셧다운중임을 알립니다. 종료 시그널 발생 // Sender.Tell("service unavailable, shutting down", Self); 2.자식 액터종료(PoisonPill, 지금까지 받은메시지까지만 처리하고) // 3.GracefulStop , Terminated 될때까지 break;대기 case// Terminated검증 t: 안전한 종료메시지가 왔는지 검사 await Context.Stop(Selfmanager.GracefulStop(TimeSpan.FromMilliseconds(3), "shutdown"); breakprobe.ExpectMsg("SafeClose", TimeSpan.FromSeconds(waitTimeSec)); } } } |
액터접근 주소체계
...
잠시
실습없이, Actor를 접근하는 주소체계에대해 설명 드리겠습니다. ActorPath는 ActorPath는 총 4가지로 구분이 되며 http의 되며 http의 RestAPI의 주소체계와 거의 흡사하다고 볼수 있습니다.
...
- RESTAPI 호출 VS RemoteActor 호출
- 항상 DB Read 가 발생하는 RESTAPI VS Actor를 사용하여 DB Read가 발생하지않는 없는 RESTAPI
-
Jira server JIRA serverId feb819c4-adfb-3d6d-aaee-7d42f588dbbe key AKKADOCU-8
...