private static async void MemberRemoved(ActorSystem actorSystem) { Thread.Sleep(2000); await actorSystem.Terminate(); ColorConsole.WriteLineGray("Left Cluster."); }
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); }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem in remote process"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); MovieStreamingActorSystem.AwaitTermination(); }
private static async Task MainAsync() { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem in remote process"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); await MovieStreamingActorSystem.WhenTerminated; }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem in remote process"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); Task.WaitAll(MovieStreamingActorSystem.WhenTerminated); }
static void Main(string[] args) { ColorConsole.WriteLineGray("creating system in remote"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); MovieStreamingActorSystem.WhenTerminated.Wait(); }
private static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem in remote process"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); MovieStreamingActorSystem.WhenTerminated.Wait(); Environment.Exit(1); }
private static void Main(string[] args) { var jobId = 1; ColorConsole.WriteLineGray("Creating Client Actor System"); var serverLocation = ConfigurationManager.AppSettings["serverLocation"]; var actorSystem = ActorSystem.Create("ConsoleClient"); ColorConsole.WriteLineGray("Creating actor supervisory hierarchy"); var logger = actorSystem.ActorSelection($"akka.tcp://{ serverLocation }/user/LogCoordinator"); var reporter = actorSystem.ActorSelection($"akka.tcp://{ serverLocation }/user/Report"); string command; do { ShortPause(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGray; ColorConsole.WriteLineGray("enter a command and hit enter"); command = Console.ReadLine() ?? string.Empty; if (command.StartsWith("log")) { var appId = command.Split(',')[1]; var logMsg = command.Split(',')[2]; var message = new LogEntryMessage(appId, LogEventType.Info, logMsg); logger.Tell(message); } if (command.StartsWith("rpt")) { var report = new ReportMessage(jobId++, command.Split(',')[1]); Task.Run(async() => { var r = reporter.Ask(report); var ack = await r; ColorConsole.WriteLineCyan(ack.ToString()); ColorConsole.WriteLineGray(""); }); } } while (command != "exit"); actorSystem.Terminate(); actorSystem.WhenTerminated.Wait(); ColorConsole.WriteLineGray("Actor system terminated"); Console.ReadKey(); Environment.Exit(1); }
private static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); ColorConsole.WriteLineGray("Creating actor supervisory hierarchy"); MovieStreamingActorSystem.ActorOf(Props.Create <PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGray; ColorConsole.WriteLineGray("enter a command and hit enter"); var command = Console.ReadLine(); if (command.StartsWith("play")) { int userId = int.Parse(command.Split(',')[1]); string movieTitle = command.Split(',')[2]; var message = new PlayMovieMessage(movieTitle, userId); MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message); } if (command.StartsWith("stop")) { int userId = int.Parse(command.Split(',')[1]); var message = new StopMovieMessage(userId); MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message); } if (command == "exit") { MovieStreamingActorSystem.Terminate(); MovieStreamingActorSystem.WhenTerminated.Wait(); ColorConsole.WriteLineGray("Actor system shutdown"); Console.ReadKey(); Environment.Exit(1); } } while (true); }
private static void Main(string[] args) { ColorConsole.WriteLineGray("Creating Demo Server Actor System"); var actorSystem = ActorSystem.Create("akkaDemo"); ColorConsole.WriteLineGray("Creating actor supervisory hierarchy"); var logger = actorSystem.ActorOf(Props.Create <LogCoordinatorActor>(), "logCoordinator"); var reporter = actorSystem.ActorOf(Props.Create <ReportActor>().WithRouter(FromConfig.Instance), "report"); var calc = actorSystem.ActorOf(Props.Create <CalcActor>().WithRouter(FromConfig.Instance), "calculator"); actorSystem.ActorOf(Props.Create(() => new ApiActor(logger, reporter, calc)), "api"); Console.ReadKey(); actorSystem.Terminate(); ColorConsole.WriteLineGray("Terminate called"); actorSystem.WhenTerminated.Wait(); ColorConsole.WriteLineGray("Actor system terminated"); Console.ReadKey(); Environment.Exit(1); }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating remote actor system [MovieStreamingActorSystem]"); var remoteSystem = ActorSystem.Create(Constants.Remote.MovieStreamingActorSystem); }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating Batch processor system on remote process at node localhost:8090"); TaskExecuterActorSystem = ActorSystem.Create("batchprocessor"); TaskExecuterActorSystem.WhenTerminated.Wait(); }