최초 프로젝트 셋팅


코드 테스트환경 구축

코드 테스트를 하기위해서 다음과 같은 방법이 있습니다.


여기서는, 마지막 방법을 사용하여 여러가지 AKKA의 기능을 테스트 하겠습니다.


사용자 정의 테스트 클래스 작성

using Akka.Actor;

namespace ServiceA.STUDY
{
    public class ActorTest  //Actor 기본 테스트를 위해서~~
    {
        protected ActorSystem actorSystem;

        public ActorTest(ActorSystem system)  //메인 APP에서 생성한 AKKA System만 참조하면 됩니다.
        {
            actorSystem = system;
        }

        public void RunAll()  //여기서 모든 테스트 코드를 분리하여,실행예정
        {

        }
    }
}


이렇게 하는 이유는 단지, 기존 어플리케이션 작동코드에서 학습 진행한 코드를 분리하기 위함입니다.

위와 같은 템플릿은 ActorTest외에 , RemoteActor , ClusterActor등 목적에따라 Class로 분리예정이며

더이상 언급하지 않겠습니다.


using Akka.Actor;

using ServiceA.STUDY;

namespace ServiceA
{
    class Program
    {
        static void Main(string[] args)
        {
            ConsoleKeyInfo cki;
            Console.CancelKeyPress += new ConsoleCancelEventHandler(myHandler);
            using (ActorSystem system = ActorSystem.Create("ServiceA"))
            {
                //Actor의 시스템 준비 완료

                //ActorTest -ActorTest코드는 아래 두줄외에 더이상 추가가 안됩니다.
                ActorTest actorTest = new ActorTest(system);
                actorTest.Run();

                while (true)
                {
                    // 메인 어플리케이션 종료방지를 위한코드 ( ctrl+x 종료 )
                    cki = Console.ReadKey(true);
                    if (cki.Key == ConsoleKey.X) break;
                }
            }
        }

        protected static void myHandler(object sender, ConsoleCancelEventArgs args)
        {
            args.Cancel = true;
        }
    }
}