Exemplo n.º 1
0
        private static void Main(string[] args)
        {
            Console.CancelKeyPress += (sender, e) =>
            {
                QuitEvent.Set();
                e.Cancel = true;
            };

            ColorConsole.WriteLineGray("Creating Remote Actor System");

            var config = ConfigurationFactory.ParseString($"akka.remote.helios.tcp.hostname = {IPUtils.LocalIPAddress()}")
                         .WithFallback(GetAkkaConfig("akka"));

            var actorSystem = ActorSystem.Create("akkaDemo", config);

            QuitEvent.WaitOne();

            ColorConsole.WriteLineGray("Shutting down");
            var cluster = Akka.Cluster.Cluster.Get(actorSystem);

            cluster.RegisterOnMemberRemoved(() => MemberRemoved(actorSystem));

            ColorConsole.WriteLineGray("Leaving Cluster...");
            cluster.Leave(cluster.SelfAddress);

            actorSystem.WhenTerminated.Wait();
            ColorConsole.WriteLineGray("Actor system terminated");

            Console.ReadKey();

            Environment.Exit(1);
        }