Page History
Info |
---|
Local Actor를 Remote Actor로 확장하는것은 아주간단한것을 알게되었습니다. 이제는 이 RemoteActor를 Router기능(예를들어 라운드로빈)으로 확장을 시도해보겠습니다. |
시나리오
- ANODE를 UP
- 인사를 그대로 돌려주는 EchoActor2 작성
- ANODE는 h1~h3 까지 3가지의 동일한 액터가 있음
- BNODE를 UP
- BNODE는 ANODE에게 설정된 라우터로 메시지를 만개보내고 그결과를 비동기적으로 받음
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using Akka.Actor; namespace CommonActor { public class Hello { public Hello(string message) { Message = message; } public string Message { get; private set; } } public class HelloReq { public HelloReq(string message) { Message = message; } public string Message { get; private set; } } public class EchoActor2 : ReceiveActor { protected int recCnt = 0; protected bool isLog() { if (recCnt < 10 || recCnt % 100 == 0) return true; else return false; } public EchoActor2() { Receive<Hello>(hello => { recCnt++; if(isLog()) Console.WriteLine("Log: [{0} -> {1} ]: {2}", Sender,Self.Path , hello.Message); Sender.Tell(new HelloReq(hello.Message)); }); Receive<HelloReq>(hello => { recCnt++; if (isLog()) Console.WriteLine("Log: [{0} -> {1} ]: {2}", Sender, Self.Path, hello.Message); }); } } } |
...