示例#1
0
        static void Main(string[] args)
        {
            var         config = ConfigurationFactory.ParseString(File.ReadAllText("App.Akka.conf"));
            ActorSystem system = ActorSystem.Create("Deployer", config);

            var cmd = PetabridgeCmd.Get(system);

            cmd.Start();

            Console.WriteLine();
            Console.WriteLine("Deployer is running...");
            Console.WriteLine();

            //
            // 환경 설정으로 배포 설정하기
            //actor {
            //    provider = remote
            //    deployment {
            //        /DeployedEchoActor1 {
            //            remote = "akka.tcp://DeployerTarget@localhost:8091"
            //        }
            //    }
            //}
            //

            //
            // 1. 배포된 액터에서 예외가 발생하면 배포한 액터에게 전달된다.
            // 2. 예외가 발생한 소스 라인 정보까지 제공한다.
            //
            // [ERROR]
            // [2019-04-25 오전 11:46:35]
            // [Thread 0003]
            // [akka.tcp://DeployerTarget@localhost:8091/remote/akka.tcp/Deployer@localhost:8081/user/DeployedEchoActor] Attempted to divide by zero.
            // Cause: System.DivideByZeroException: Attempted to divide by zero.
            //    at DeployerShared.DeployedEchoActor.Handle(Int32 msg) in C:\Labs\Akka.NET-Labs\ClusterLab\04. Warm-up For Cluster Routing\04. Deploy - Hanlde Exceptions Raised by Deployed Actors\DeployerShared\DeployedEchoActor.cs:line 41
            //    at DeployerShared.DeployedEchoActor.<.ctor>b__2_0(Int32 _) in C:\Labs\Akka.NET-Labs\ClusterLab\04. Warm-up For Cluster Routing\04. Deploy - Hanlde Exceptions Raised by Deployed Actors\DeployerShared\DeployedEchoActor.cs:line 34
            //    at lambda_method(Closure, Object, Action`1)
            //    at Akka.Actor.ReceiveActor.ExecutePartialMessageHandler(Object message, PartialAction`1 partialAction)
            //    at Akka.Actor.UntypedActor.Receive(Object message)
            //    at Akka.Actor.ActorBase.AroundReceive(Receive receive, Object message)
            //    at Akka.Actor.ActorCell.ReceiveMessage(Object message)
            //    at Akka.Actor.ActorCell.Invoke(Envelope envelope)
            //
            var deployedEchoActor = system.ActorOf(DeployedEchoActor.Props(), nameof(DeployedEchoActor));

            deployedEchoActor.Tell(0);

            Console.ReadLine();
        }
示例#2
0
        static void Main(string[] args)
        {
            var         config = ConfigurationFactory.ParseString(File.ReadAllText("App.Akka.conf"));
            ActorSystem system = ActorSystem.Create("Deployer", config);

            var cmd = PetabridgeCmd.Get(system);

            cmd.Start();

            // 환경 설정으로 배포 설정하기
            //actor {
            //    provider = remote
            //    deployment {
            //        /DeployedEchoActor1 {
            //            remote = "akka.tcp://DeployerTarget@localhost:8091"
            //        }
            //    }
            //}
            //
            // FAQ. "EchoActor1" 이름이 일치하지 않으면 로컬로 배포된다.
            var deployedEchoActor1 = system.ActorOf(DeployedEchoActor.Props(), nameof(DeployedEchoActor) + "1");

            //
            // vs.
            //

            // 코드로 배포 설정하기
            var deployedEchoActor2 =
                system.ActorOf(
                    DeployedEchoActor
                    .Props()
                    .WithDeploy(Deploy.None.WithScope(new RemoteScope(
                                                          Address.Parse("akka.tcp://DeployerTarget@localhost:8091")))),
                    nameof(DeployedEchoActor) + "2");

            system.ActorOf(LocalActor.Props(deployedEchoActor1), nameof(LocalActor) + "1");
            system.ActorOf(LocalActor.Props(deployedEchoActor2), nameof(LocalActor) + "2");

            Console.WriteLine();
            Console.WriteLine("Deployer is running...");
            Console.WriteLine();

            Console.ReadLine();
        }