public static void TerminateActorSystem() { ColoredConsole.WriteTitle(" Quitting..."); // Terminate an ActorSystem ActorSystemHelper.TerminateActorSystem(); }
static void Main(string[] args) { try { ColoredConsole.WriteTitle("MoviePlaybackSystem: Running Akka.NET demo..."); // Start ActorSystem MoviePlaybackSystemHelper.StartActorSystem(true); ActorPaths.LogAllActorPaths(); // Run interactive session with user inputting commands RunUserInteractiveSession(); // Terminate ActorSystem // MoviePlaybackSystemHelper.TerminateActorSystem(); ColoredConsole.WriteTitle("MoviePlaybackSystem: Quitting Akka.NET demo."); } catch (Exception ex) { ColoredConsole.WriteError($"MoviePlaybackSystem: Exception occurred (type: '{ex.GetType().Name}')"); ColoredConsole.WriteError(ex.Message); ColoredConsole.WriteError(ex.StackTrace); } finally { // Terminate ActorSystem MoviePlaybackSystemHelper.TerminateActorSystem(); } }
static void Main(string[] args) { try { ColoredConsole.WriteTitle("MoviePlaybackSystem.Remote.PlaybackStatisticsActor: Running Akka.NET demo..."); // Start ActorSystem MoviePlaybackSystemHelper.StartActorSystem(false); ActorPaths.LogAllActorPaths(); // Wait for user input to terminate the application ColoredConsole.WriteUserPrompt($" Press ENTER key to terminate '{MoviePlaybackSystemHelper.ActorSystemName}' ActorSystem..."); Console.ReadLine(); // Terminate ActorSystem // MoviePlaybackSystemHelper.TerminateActorSystem(); ColoredConsole.WriteTitle("MoviePlaybackSystem.Remote.PlaybackStatisticsActor: Quitting Akka.NET demo."); } catch (Exception ex) { ColoredConsole.WriteError($"MoviePlaybackSystem.Remote.PlaybackStatisticsActor: Exception occurred (type: '{ex.GetType().Name}')"); ColoredConsole.WriteError(ex.Message); ColoredConsole.WriteError(ex.StackTrace); } finally { // Terminate ActorSystem MoviePlaybackSystemHelper.TerminateActorSystem(); } }
public static void LogAllActorPaths() { ColoredConsole.WriteTitle($"Logging all actors paths: "); ColoredConsole.WriteTitle($" MoviePlaybackActor: {ActorPaths.MoviePlaybackActor.Path}"); ColoredConsole.WriteTitle($" PlaybackStatisticsActor: {ActorPaths.PlaybackStatisticsActor.Path}"); ColoredConsole.WriteTitle($" MoviePlayCounterActor: {ActorPaths.MoviePlayCounterActor.Path}"); ColoredConsole.WriteTitle($" UserCoordinatorActor: {ActorPaths.UserCoordinatorActor.Path}"); string exampleUserId = "999"; ColoredConsole.WriteTitle($" UserActor({exampleUserId}): {ActorPaths.GetUserActorMetaData(exampleUserId).Path}"); }
public static void StartActorSystem(bool createRootActor = false) { ActorSystemName = Constants.ActorSystemName; // Create an ActionSystem ColoredConsole.WriteTitle($"Creating '{ActorSystemName}' ActorSystem..."); // Create an Akka ActorSystem ActorSystemHelper.CreateActorSystem(ActorSystemName); if (createRootActor == true) { // Create first 'user' actor 'MoviePlaybackActor' in Akka ActorSystem _moviePlaybackActorRef = ActorSystemHelper.CreateActor(MoviePlaybackActor.Props(), ActorPaths.MoviePlaybackActor.Name); } }
public static void CreateActorSystem(string actorSystemName) { // Read Akka configuration and create an ActionSystem Config config = HoconConfiguration.ReadAndParse(Constants.AkkaConfigurationFileName); ColoredConsole.WriteTitle($"Application Name: {config.GetString("application.info.name")}"); if (AkkaActorSystem == null) { AkkaActorSystem = ActorSystem.Create(actorSystemName, config); ColoredConsole.WriteCreationEvent($"CREATED '{actorSystemName}' ActorSystem."); } var petabridgeCmdHost = PetabridgeCmd.Get(GetAkkaActorSystem()); petabridgeCmdHost.RegisterCommandPalette(Petabridge.Cmd.Remote.RemoteCommands.Instance); petabridgeCmdHost.Start(); }