private static void Main(string[] args) { MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.WriteLine("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); } } while (true); }
public IActionResult PostUsers(string userName, string region) { var message = new NewRegionUser(userName); var selection = ActorSystem.ActorSelection($"/user/RegionMaster:{region}"); selection.Tell(message); return(Ok()); }
static void Main(string[] args) { using (ActorSystem system = ActorSystem.Create("messageSystem")) { var coordinator = system.ActorOf(Props.Create <CoordinatorActor>(), "server1"); var start = new Messages.StartSession("user1", "group1"); //create a new user session var command = coordinator. Ask <Messages.CommandProcessedAck>(start); //wait until complete command.Wait(); //Tell the coordinator to increment the state of the newly created //user session coordinator.Tell(new Messages.IncrementState("user1", "group1")); //Tell the newly created actor directly to increment state using actor selection var handler = system.ActorSelection("akka://messageSystem/user/server1/group1/user1"); handler.Tell(new Messages.IncrementState("user1", "group1")); //Query through the coordinator the current state of the newly created actor var query1 = coordinator.Ask(new Messages.QueryUserActorState("user1", "group1")); query1.Wait(); var result1 = query1.Result as Messages.QueryUserActionStateResult; Console.WriteLine("Results from query 1"); Console.WriteLine(result1.State.CurrentValue); //query the state directly of the newly created actor using Actor Selection var query2 = handler.Ask(new Messages.QueryUserActorState("user1", "group1")); query2.Wait(); var result = query2.Result as Messages.QueryUserActionStateResult; //query the state of the newly created actor through the group using Actor Selection var handler2 = system.ActorSelection("akka://messageSystem/user/server1/group1"); var query3 = handler2.Ask(new Messages.QueryUserActorState("user1", "group1")); query3.Wait(); var result2 = query3.Result as Messages.QueryUserActionStateResult; Console.WriteLine("Results from query 2"); Console.WriteLine(result.State.CurrentValue); Console.WriteLine("Results for query 3"); Console.WriteLine(result2.State.CurrentValue); handler.Tell(new Messages.EndSession("user1", "group1")); Console.WriteLine("Finished"); Console.ReadLine(); } }
public async Task <string> AddMessage(string userId, string message, string chatRoomName) { var chatRoomActor = _actorSystem.ActorSelection("/user/" + MakeActorName(chatRoomName)); var addMessage = new AddChatMessage(chatRoomName, userId, message); var answer = await chatRoomActor.Ask <ReturnMessage>(addMessage); return(answer.Message); }
public async Task <IActionResult> GetQuestion(string sessionId, string questionId) { var quizCoordinator = _quizActorSystem.ActorSelection("/user/QuizMasterActor/QuizSessionCoordinatorActor/"); var quizSession = await quizCoordinator.Ask <IActorRef>(sessionId); // assuming some part of the session has the quiz Id var retrieveQuestionMessage = new RetrieveQuestionMessage(sessionId, sessionId.Split('-')[0], questionId); var question = await quizSession.Ask <Question>(retrieveQuestionMessage); return(Ok(question)); }
static void Main(string[] args) { Console.WriteLine("Creating MovieStreamingActorSystem", Color.Gray); var config = ConfigurationFactory.ParseString(File.ReadAllText("settings.hocon")); using (MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorLocalSystem", config)) { Console.WriteLine("Actor System created"); Console.WriteLine("Creating actor supervisory hierarchy", Color.Gray); Props playbackActorProps = Props.Create <PlaybackActor>(); MovieStreamingActorSystem.ActorOf(playbackActorProps, "PlaybackActor"); Task.Delay(TimeSpan.FromSeconds(1)).Wait(); // so that the messages from the system come before the user prompt is displayed do { Console.WriteLine(); Console.WriteLine("Enter a command and hit enter", Color.DarkGray); var command = Console.ReadLine(); if (command.StartsWith("play")) { var userId = int.Parse(command.Split(',')[1]); var movieTitle = command.Split(',')[2]; var message = new PlayMovieMessage(movieTitle, userId); MovieStreamingActorSystem.ActorSelection("/user/PlaybackActor/UserCoordinatorActor").Tell(message); } if (command.StartsWith("stop")) { var userId = int.Parse(command.Split(',')[1]); var message = new StopMovieMessage(userId); MovieStreamingActorSystem.ActorSelection("/user/PlaybackActor/UserCoordinatorActor").Tell(message); } if (command.StartsWith("exit")) { MovieStreamingActorSystem.Terminate(); Console.WriteLine("Actor System terminating", Color.Gray); MovieStreamingActorSystem.WhenTerminated.Wait(); Console.WriteLine("Actor System terminated", Color.Gray); Console.ReadLine(); Environment.Exit(0); } } while (true); } }
public void Start() { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem"); _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); ColorConsole.WriteLineGray("Creating actor supervisory hierarchy"); _movieStreamingActorSystem.ActorOf(Props.Create <PlaybackActor>(), "Playback"); while (true) { Thread.Sleep(500); Console.WriteLine(); ColorConsole.WriteGray("Enter command > "); string command = Console.ReadLine(); if (command == null) { continue; } command = command.ToLower(); string[] commandArray = command.Split(','); if (command.StartsWith("play")) { int userId = int.Parse(commandArray[1]); string movieTitle = commandArray[2]; PlayMovieMessage message = new PlayMovieMessage(movieTitle, userId); const string selector = "/user/Playback/UserCoordinator"; _movieStreamingActorSystem.ActorSelection(selector).Tell(message); } if (command.StartsWith("stop")) { int userId = int.Parse(commandArray[1]); StopMovieMessage message = new StopMovieMessage(userId); const string selector = "/user/Playback/UserCoordinator"; _movieStreamingActorSystem.ActorSelection(selector).Tell(message); } if (command == "exit") { _movieStreamingActorSystem.Terminate(); ColorConsole.WriteLineGray("Actor system shutdown"); break; } } }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); ColorConsole.WriteLineGray("Creating actor supervisor hierarchy"); MovieStreamingActorSystem.ActorOf(Props.Create <PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); ColorConsole.WriteLineDarkGray("Input a command and hit Enter"); string command = Console.ReadLine(); string[] split = command.Split(","); string action = split[0]; ActorSelection userCoordinatorActor = MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator"); ActorSelection playbackStatisticsActor = MovieStreamingActorSystem.ActorSelection("/user/Playback/PlaybackStatistics"); if (action.Equals("play")) { int userId = int.Parse(split[1]); string movieTitle = split[2]; var message = new PlayMovieMessage(movieTitle, userId); userCoordinatorActor.Tell(message); playbackStatisticsActor.Tell(message); } if (command.StartsWith("stop")) { int userId = int.Parse(split[1]); var message = new StopMovieMessage(userId); userCoordinatorActor.Tell(message); } if (command.StartsWith("exit")) { MovieStreamingActorSystem.Terminate(); ColorConsole.WriteLineGray("Actor system shutdown"); Console.ReadKey(); Environment.Exit(1); } } while (true); }
static void Main(string[] args) { Console.Title = $"Client:{Ports.Client}"; Console.ForegroundColor = ConsoleColor.DarkMagenta; Config config = AkkaDistributedHelper.GetAkkaSettings(); string routerAddress = $"{AkkaDistributedHelper.GetFullyQualifiedDomainName()}:{Ports.Client}"; config = config .WithFallback(string.Format("akka.remote.dot-netty.tcp.hostname = \"{0}\"", AkkaDistributedHelper.GetFullyQualifiedDomainName())) .WithFallback(string.Format("akka.remote.dot-netty.tcp.port = {0}", Ports.Client)) .WithFallback(string.Format("akka.cluster.roles = [\"{0}\"]", NamesRegistry.Client)) .WithFallback(string.Format("akka.cluster.seed-nodes = [\"{1}://App-Client@{0}\"]", routerAddress, AkkaDistributedHelper.TcpProtocol)); MyActorSystem = ActorSystem.Create("App-Client"); bool isClusterClientInitialized = false; string routerActorPath = string.Format("{3}://App-Cluster@{0}:{1}/user/{2}", AkkaDistributedHelper.GetFullyQualifiedDomainName(), Ports.Router, NamesRegistry.Router, TcpProtocol); while (true) { Console.WriteLine("Press any key to trigger evaluation, q to exit"); if (Console.ReadKey().KeyChar != 'q') { if (!isClusterClientInitialized) { InitializeProgressSubscription(); isClusterClientInitialized = true; } MyActorSystem.ActorSelection(routerActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result.Tell(new RouterActor.EvaluationRequested()); } else { break; } } IActorRef router = MyActorSystem.ActorSelection(routerActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result; router.Tell(new RouterActor.ShutdownRequested()); Console.WriteLine(); Console.WriteLine("Exiting, sent shutdown..."); }
public static void Run() { const string config = @"akka { actor { provider = ""Akka.Remote.RemoteActorRefProvider,Akka.Remote"" } remote { helios.tcp { port = 10085 hostname = localhost } } } }"; ActorSystem system = ActorSystem.Create("MyActorSystem", ConfigurationFactory.ParseString(config)); var printer = system.ActorSelection(@"akka.tcp://MyActorSystem@localhost:8095/user/MessagePrinter"); string input = ""; while (ReadUserInputUntillQuit("Enter a Message", out input)) { Console.WriteLine("Sending {0} from thread {1}", input, Thread.CurrentThread.ManagedThreadId); printer.Tell(new Message(input)); } }
static void Main(string[] args) { // Akka prefers creation of objects via factories // this is due to the fact that internally Akka does a lot of system internally UntypedActorSystem = ActorSystem.Create("UntypedActorSystem"); Console.WriteLine("Actor system created"); // Akka uses the movie industry to name a few items // To create an Actor you use the Props class Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>(); // ActorOf will create the Actor // You can get a reference to the Actor using the ActorOf which returns an IActorRef UntypedActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain"); // Alternatively you can use ActorSelection and a path to the Actor ActorSelection whatsMyTypeAgainActor = UntypedActorSystem.ActorSelection("/user/WhatsMyTypeAgain"); // Tell is void whatsMyTypeAgainActor.Tell("I'm 30"); // Ask with return a value (request response) var askTask = whatsMyTypeAgainActor.Ask<int>("Hey what's my age again?"); Task.WaitAll(askTask); Console.WriteLine(askTask.Result); Console.ReadKey(); UntypedActorSystem.Shutdown(); UntypedActorSystem.AwaitTermination(); }
public static async Task <List <ChartModel> > DisplayTemperatures() { var temps = await ActorSystem.ActorSelection( "akka://building-iot-system/user/buildings-manager/building-basement") .Ask <RespondAllTemperatures>(new RequestAllTemperatures(0)); var data = new List <ChartModel>(); int dataCount = 0; foreach (var temp in temps.TemperatureReadings) { Console.Write($"Device {temp.Key} {temp.Value.GetType().Name}"); dataCount++; if (temp.Value is TemperatureAvailable) { int tempInt = ((TemperatureAvailable)temp.Value).Temperature; //Int32.TryParse(tempDouble.ToString(), out int deger); //data.Add(new ChartModel { Data = new List<double> { tempDouble }, Label = $"Data{dataCount}" }); data.Add(new ChartModel { Data = tempInt, Label = $"Data{dataCount}" }); } //Console.WriteLine(" "); } return(data); }
static void Main(string[] args) { // Akka prefers creation of objects via factories // this is due to the fact that internally Akka does a lot of system internally ReceiveActorSystem = ActorSystem.Create("ReceiveActorSystem"); Console.WriteLine("Actor system created"); // Akka uses the movie industry to name a few items // To create an Actor you use the Props class Props whatsMyTypeAgainProps = Props.Create<WhatsMyTypeAgainActor>(); // ActorOf will create the Actor // You can get a reference to the Actor using the ActorOf which returns an IActorRef ReceiveActorSystem.ActorOf(whatsMyTypeAgainProps, "WhatsMyTypeAgain"); // Alternatively you can use ActorSelection and a path to the Actor ActorSelection whatsMyTypeAgainActor = ReceiveActorSystem.ActorSelection("/user/WhatsMyTypeAgain"); // Tell is void whatsMyTypeAgainActor.Tell("I'm 30"); whatsMyTypeAgainActor.Tell("I'm 31"); // This message is ignored since the Actor's behavior has changed whatsMyTypeAgainActor.Tell(30); Console.ReadKey(); ReceiveActorSystem.Shutdown(); ReceiveActorSystem.AwaitTermination(); Console.ReadKey(); }
static void Main(string[] args) { _exploringRemotingActorSystem = ActorSystem.Create("ExploringRemotingActorSystem"); ColorConsole.WriteLineGreen("Created the Local ExploringRemotingActorSystem. " + "RandomTextCoordinatorActor will live here and deploy RandomTextActors to the remote instance"); Props randomTextActorCoordinatorProps = Props.Create<RandomTextCoordinatorActor>(); _exploringRemotingActorSystem.ActorOf(randomTextActorCoordinatorProps, "RandomTextCoordinator"); ColorConsole.WriteLineGreen("Created RandomTextCoordinator"); var random = new Random(0); do { Thread.Sleep(500); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGray; ColorConsole.WriteLineGray("Hit enter to receive random text..."); var input = Console.ReadLine(); if (input == "q") { return; } for (int i = 0; i < 10000; i++) { Task.Run(() => { RandomTextMessage rtm = new RandomTextMessage(random.Next(0, 5)); _exploringRemotingActorSystem.ActorSelection("/user/RandomTextCoordinator").Tell(rtm); }); } } while (true); }
static public void Start(IApplicationBuilder app, ActorSystem actorSystem) { // http://wiki.webnori.com/display/AKKA/Actors // HelloActor 기본액터 AkkaLoad.RegisterActor("helloActor" /*AkkaLoad가 인식하는 유니크명*/, actorSystem.ActorOf(Props.Create(() => new HelloActor("webnori")), "helloActor" /*AKKA가 인식하는 Path명*/)); var helloActor = actorSystem.ActorSelection("user/helloActor"); var helloActor2 = AkkaLoad.ActorSelect("helloActor"); helloActor.Tell("hello"); helloActor2.Tell("hello"); // 밸브 Work : 초당 작업량을 조절 int timeSec = 1; int elemntPerSec = 5; var throttleWork = AkkaLoad.RegisterActor("throttleWork", actorSystem.ActorOf(Props.Create(() => new ThrottleWork(elemntPerSec, timeSec)), "throttleWork")); // 실제 Work : 밸브에 방출되는 Task를 개별로 처리 var worker = AkkaLoad.RegisterActor("worker", actorSystem.ActorOf(Props.Create <WorkActor>(), "worker")); // 밸브 작업자를 지정 throttleWork.Tell(new SetTarget(worker)); //StartLoadTestByRouter(app,actorSystem); //StartLoadTestByPingPong(app,actorSystem); //StartKafkaTest(app, actorSystem); }
public DomainBus() { _system = ActorSystem.Create("LocalSystem"); var config = _system.Settings.Config; _domain = _system.ActorSelection(config.GetString("akka.actor.address.entry")); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { system = ActorSystem.Create("MyClientSystem"); serverActor = system.ActorSelection("akka.tcp://TestServer@localhost:8081/user/MyServerActor"); uiActor = system.ActorOf(Props.Create(() => new UIActor(this.textBox)), "MyClient"); clientActor = system.ActorOf(Props.Create(() => new ClientActor(serverActor, uiActor)), Guid.NewGuid().ToString()); }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) { system = ActorSystem.Create("MyClientSystem"); serverActor = system.ActorSelection("akka.tcp://TestServer@localhost:8081/user/MyServerActor"); uiActor = system.ActorOf(Props.Create(() => new UIActor(this.textBox)), "MyClient"); clientActor = system.ActorOf(Props.Create(() => new ClientActor(serverActor, uiActor)), Guid.NewGuid().ToString()); }
public AkkaSystemService() { _actorSystem = ActorSystem.Create("akka-demo-playerservice", @"akka { stdout-loglevel = DEBUG loglevel = DEBUG log-config-on-start = on actor { provider = remote debug { receive = on autoreceive = on lifecycle = on event-stream = on unhandled = on } } } "); //Resolve on remote system !! var _gameSelection = _actorSystem.ActorSelection("akka.tcp://akka-demo-gameserver@gameserver:8888/user/game1"); var _gameIdentificationTask = _gameSelection.Ask <ActorIdentity>(new Identify(0)); _gameIdentificationTask.Wait(); _game = _gameIdentificationTask.Result.Subject; ColorConsole.WithYellowText.WriteLine("Resolved remote game actor"); //We will create players dynamically now //_player1 = _actorSystem.ActorOf<PlayerActor>("player1"); //_player2 = _actorSystem.ActorOf<PlayerActor>("player2"); //_player3 = _actorSystem.ActorOf<PlayerActor>("player3"); }
/// <summary> /// This is the main entry point for your service instance. /// </summary> /// <param name="cancellationToken">Canceled when Service Fabric needs to shut down this service instance.</param> protected override async Task RunAsync(CancellationToken cancellationToken) { ServicePartitionResolver resolver = ServicePartitionResolver.GetDefault(); ResolvedServicePartition partition = await resolver.ResolveAsync(new Uri(@"fabric:/my_akka_remote_service_fabric/MyStatelessGreeter"), new ServicePartitionKey(), cancellationToken); var endpoint = partition.GetEndpoint(); JObject addresses = JObject.Parse(endpoint.Address); string primaryReplicaAddress = (string)addresses["Endpoints"].First(); var greeter = _actorSystem.ActorSelection(primaryReplicaAddress + "/user/greeter"); long iterations = 0; while (true) { cancellationToken.ThrowIfCancellationRequested(); iterations++; var name = $"MyStatelessGreetee: {iterations}, {this.Context.NodeContext.NodeName}"; greeter.Tell(new GreetMessage(name)); ServiceEventSource.Current.ServiceMessage(this.Context, "MyStatelessGreeter is working-{0}", ++iterations); await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken); } }
public void Setup() { _timeout = TimeSpan.FromMinutes(1); _system = ActorSystem.Create("system"); _echo = _system.ActorOf(Props.Create(() => new EchoActor()), "echo"); _actorSelection = _system.ActorSelection("/user/echo"); }
public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo"); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)), "benchmark"); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark"; try { // set the timeout high here to avoid timeouts // TL;DR; - on slow machines it can take longer than 2 seconds to form the association, do the handshake, and reply back // using the in-memory transport. _remoteReceiver = System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result; _remoteEcho = System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; } catch (Exception ex) { context.Trace.Error(ex, "error occurred during setup."); throw; // re-throw the error to blow up the benchmark } }
static void Main(string[] args) { int numberOfStores = 1; // start system using (ActorSystem system = ActorSystem.Create("warehouse")) { // create child actors IActorRef inventoryActor = system.ActorOf <InventoryActor>("inventory"); IActorRef salesActor = system.ActorOf <SalesActor>("sales"); salesActor.Tell(new DumpSales()); IActorRef backorderActor = system.ActorOf <BackorderActor>("backorder"); Console.WriteLine("Press any key to open the stores..."); Console.ReadKey(true); // start store simulation for (int i = 0; i < numberOfStores; i++) { Props props = Props.Create <StoreActor>(new object[] { i }); system.ActorOf(props, $"store{i}"); } Console.ReadKey(true); // keep the actorsystem alive // dump backorders Console.WriteLine("\nDumping backorders"); system.ActorSelection("/user/backorder").Tell(new DumpBackorders()); Console.ReadKey(true); } }
private static void Main(string[] args) { var builder = new ContainerBuilder(); builder.RegisterType <SimpleTrendingMovieAnalyzer>().As <ITrendingMovieAnalyzer>(); builder.RegisterType <TrendingMoviesActor>(); var container = builder.Build(); var logger = new LoggerConfiguration() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); Serilog.Log.Logger = logger; MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); var resolver = new AutoFacDependencyResolver(container, MovieStreamingActorSystem); MovieStreamingActorSystem.ActorOf(Props.Create <PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.WriteLine("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); } } while (true); }
private static void Main(string[] args) { Console.WriteLine("Creating MovieStreamingActorSystem"); _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); Console.WriteLine("Creating actor supervisory hierarchy"); _movieStreamingActorSystem.ActorOf(Props.Create <PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.DarkGray; Console.WriteLine("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().Wait(); Console.WriteLine("Actor system shutdown"); Console.ReadKey(); Environment.Exit(1); return; } } while (true); }
static void Main(string[] args) { var builder = new ContainerBuilder(); builder.RegisterType <SimpleTrendingMovieAnalyzer>().As <ITrendingMovieAnalyzer>(); builder.RegisterType <TrendingMoviesActor>(); var container = builder.Build(); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); IDependencyResolver resolver = new AutoFacDependencyResolver(container, MovieStreamingActorSystem); 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); } else if (command.StartsWith("stop")) { int userId = int.Parse(command.Split(',')[1]); var message = new StopMovieMessage(userId); MovieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message); } else if (command == "exit") { Terminate(); } } while (true); }
private void _init() { _log.Debug("初始化监听sina的作业"); actorSystem = ActorSystem.Create(ConstantsHelper.AKKA_PATH_SERVER); // var path = String.Format("akka.tcp://{2}@localhost:8091/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation", ConstantsHelper.AKKA_PATH_SERVER); var path = String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation"); sinaActor = actorSystem.ActorSelection(path); }
private static void Main(string[] args) { _movieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); Console.WriteLine(string.Format("{0} started...", _movieStreamingActorSystem.Name)); var playbackActorProps = Props.Create<PlaybackActor>(); var playbackActorRef = _movieStreamingActorSystem.ActorOf(playbackActorProps, "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")) { var userId = int.Parse(command.Split(',')[1]); var movieTitle = command.Split(',')[2]; var message = new PlayMovieMessage(movieTitle, userId); _movieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message); } if (command.StartsWith("stop")) { var userId = int.Parse(command.Split(',')[1]); var message = new StopMovieMessage(userId); _movieStreamingActorSystem.ActorSelection("/user/Playback/UserCoordinator").Tell(message); } if (command == "exit") { _movieStreamingActorSystem.Shutdown(); _movieStreamingActorSystem.AwaitTermination(); ColorConsole.WriteLineGray("Actor system shutdown"); Console.ReadKey(); Environment.Exit(1); } } while (true); }
private void Initialize() { ActorSystem = ActorSystem.Create("User-Feedback-Cluster"); var remotePersistenceActor = ActorSystem.ActorSelection(ConfigurationManager.AppSettings["UserFeedbackPersistenceActor"]); ActorSystem.ActorOf(Props.Create(() => new UserFeedbackProcessorActor(remotePersistenceActor)), "UserFeedbackProcessor"); }
private static void Main(string[] args) { var builder = new ContainerBuilder(); builder.RegisterType<SimpleTrendingMovieAnalyzer>().As<ITrendingMovieAnalyzer>(); builder.RegisterType<TrendingMoviesActor>(); var container = builder.Build(); var logger = new LoggerConfiguration() .WriteTo.Seq("http://localhost:5341") .CreateLogger(); Serilog.Log.Logger = logger; MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); var resolver = new AutoFacDependencyResolver(container, MovieStreamingActorSystem); MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.WriteLine("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); } } while (true); }
public async Task InitializeFeatureForChannel(string eventMsg) { // TODO: Remove the magic string -- refactor into a method call on another object Feature = await ActorSystem .ActorSelection($"/user/channelmanager/channel_{Channel}/event_{eventMsg}") .Ask(new GetFeatureForChannel(Channel, typeof(T))) as T; }
protected override void OnStartup(StartupEventArgs e) { UIActors.ActorOf( Props.Create <DispatcherCoordinatorActor>(), ActorNames.DispatcherCoordinator); UIActors.ActorSelection(ActorPaths.Initializer).Tell(new Initialize()); }
public void GetWidgetConfiguration() { var configActorRef = ActorSystem.ActorSelection(BotConfiguration.ChannelConfigurationInstancePath).ResolveOne(TimeSpan.FromSeconds(5)).GetAwaiter().GetResult(); var channelConfiguration = configActorRef.Ask <ChannelConfiguration>(new MSG.GetConfigurationForChannel(ChannelName)).GetAwaiter().GetResult(); Configuration = channelConfiguration.FeatureConfigurations[nameof(UserActivityConfiguration)] as UserActivityConfiguration; }
// rename container ... public AkkaDataService(IUnityContainer container, IEventAggregator eventAggregator) { var config = ConfigurationFactory.ParseString(@" akka { actor { provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" } remote { helios.tcp { transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"" applied-adapters = [] transport-protocol = tcp port = 0 hostname = localhost } } } "); _system = ActorSystem.Create("WebDB", config); _resolver = new UnityDependencyResolver(container, _system); var chatClient = _system.ActorOf(_resolver.Create <DBClientActor>(), "DBClientActor"); _system.ActorSelection("akka.tcp://WebDB@localhost:8081/user/DBEntityRoot"); chatClient.Tell(new GetAllRequest("Party")); /* * while (true) { System.Threading.Thread.Sleep(10); } * * while (true) * { * var input = Console.ReadLine(); * if (input.StartsWith("/")) * { * var parts = input.Split(' '); * var cmd = parts[0].ToLowerInvariant(); * var rest = string.Join(" ", parts.Skip(1)); * * //if (cmd == "/nick") * //{ * // chatClient.Tell(new NickRequest * // { * // NewUsername = rest * // }); * //} * } * //else * //{ * // chatClient.Tell(new SayRequest() * // { * // Text = input, * // }); * //} * } * } */ }
static void Main(string[] args) { ColorConsole.WriteLineGray("Creating MovieStreamingActorSystem"); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); Console.WriteLine("Actor system created."); 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.StartsWith("exit")) { MovieStreamingActorSystem.Shutdown(); MovieStreamingActorSystem.AwaitTermination(); ColorConsole.WriteLineGray("Actor system shutdown"); Console.ReadKey(); Environment.Exit(1); } } while (true); }
static void Main(string[] args) { MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); Console.WriteLine("created"); IActorRef userActorRef = MovieStreamingActorSystem.ActorOf( Props.Create <PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); ColorConsole.WriteLineGray("enter a command and hit"); 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.StartsWith("exit")) { MovieStreamingActorSystem.Terminate(); MovieStreamingActorSystem.WhenTerminated.Wait(); Console.WriteLine("Terminated"); Console.ReadKey(); Environment.Exit(1); } } while (true); }
public UserFeedbackManager(ActorSystem actorSystem) { _remoteProcessorActor = actorSystem.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "processor"); _remotePersistenceActor = actorSystem.ActorSelection(ConfigurationManager.AppSettings["UserFeedbackPersistenceActor"]); actorSystem.ActorOf(Props.Create(() => new UserFeedbackUpdateActor(this)), "UserFeedbackUpdate"); _stopwatch = new Stopwatch(); }
public void ActorSystemActorSelection(ApplicationEnvironment applicationEnvironment) { ActorSystem actorSystem = ActorSystem.Create("app"); actorSystem.ActorOf <EchoActor>("echoActor1"); actorSystem.ActorOf <EchoActor>("echoActor2"); actorSystem.ActorOf <EchoActor>("echoActor3"); actorSystem.ActorSelection("/user/*").Tell("Send Message to Actors"); }
private void _init() { _log.Debug("初始化监听sina的作业"); actorSystem = ActorSystem.Create(ConstantsHelper.AKKA_PATH_SERVER); // var path = String.Format("akka.tcp://{2}@localhost:8091/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation", ConstantsHelper.AKKA_PATH_SERVER); var path = String.Format("/user/{0}/{1}", ConstantsHelper.AKKA_PATH_MARKET_MANAGER, "sina.quotation"); sinaActor = actorSystem.ActorSelection(path); }
public UntrustedSpec() : base(@" akka.actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" akka.remote.untrusted-mode = on akka.remote.trusted-selection-paths = [""/user/receptionist"", ] akka.remote.helios.tcp = { port = 0 hostname = localhost } akka.loglevel = DEBUG ") { _client = ActorSystem.Create("UntrustedSpec-client", ConfigurationFactory.ParseString(@" akka.actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" akka.remote.helios.tcp = { port = 0 hostname = localhost } ").WithFallback(Sys.Settings.Config)); _address = Sys.AsInstanceOf<ExtendedActorSystem>().Provider.DefaultAddress; _receptionist = Sys.ActorOf(Props.Create(() => new Receptionist(TestActor)), "receptionist"); _remoteDaemon = new Lazy<IActorRef>(() => { var p = CreateTestProbe(_client); _client.ActorSelection(new RootActorPath(_address)/_receptionist.Path.Elements) .Tell(new IdentifyReq("/remote"), p.Ref); return p.ExpectMsg<ActorIdentity>().Subject; }); _target2 = new Lazy<IActorRef>(() => { var p = CreateTestProbe(_client); _client.ActorSelection(new RootActorPath(_address)/_receptionist.Path.Elements) .Tell(new IdentifyReq("child2"), p.Ref); var actorRef = p.ExpectMsg<ActorIdentity>().Subject; return actorRef; }); EventFilter.Debug().Mute(); }
// rename container ... public AkkaDataService(IUnityContainer container, IEventAggregator eventAggregator) { var config = ConfigurationFactory.ParseString(@" akka { actor { provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" } remote { helios.tcp { transport-class = ""Akka.Remote.Transport.Helios.HeliosTcpTransport, Akka.Remote"" applied-adapters = [] transport-protocol = tcp port = 0 hostname = localhost } } } "); _system = ActorSystem.Create("WebDB", config); _resolver = new UnityDependencyResolver(container, _system); var chatClient = _system.ActorOf(_resolver.Create<DBClientActor>(), "DBClientActor"); _system.ActorSelection("akka.tcp://WebDB@localhost:8081/user/DBEntityRoot"); chatClient.Tell(new GetAllRequest("Party")); /* while (true) { System.Threading.Thread.Sleep(10); } while (true) { var input = Console.ReadLine(); if (input.StartsWith("/")) { var parts = input.Split(' '); var cmd = parts[0].ToLowerInvariant(); var rest = string.Join(" ", parts.Skip(1)); //if (cmd == "/nick") //{ // chatClient.Tell(new NickRequest // { // NewUsername = rest // }); //} } //else //{ // chatClient.Tell(new SayRequest() // { // Text = input, // }); //} } } */ }
private static void Main(string[] args) { var container = new WindsorContainer(); container.Register(Component.For<ITrendingMovieAnalyzer>().ImplementedBy<SimpleTrendingMovieAnalyzer>()); container.Register(Component.For<TrendingMoviesActor>()); MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); IDependencyResolver resolver = new WindsorDependencyResolver(container, MovieStreamingActorSystem); MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.WriteLine("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); } } while (true); }
private static void Main(string[] args) { var logger = new LoggerConfiguration() .WriteTo.Seq("http://localhost:5341") .MinimumLevel.Information() .CreateLogger(); Serilog.Log.Logger = logger; MovieStreamingActorSystem = ActorSystem.Create("MovieStreamingActorSystem"); MovieStreamingActorSystem.ActorOf(Props.Create<PlaybackActor>(), "Playback"); do { ShortPause(); Console.WriteLine(); Console.WriteLine("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); } } while (true); }
static void Main(string[] args) { _actorSystem = ActorSystem.Create("coach"); var actor = _actorSystem.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "event"); _actorSystem.ActorOf(Props.Create<StartSupervisorActor>(actor), "supervisor"); var startActor = _actorSystem.ActorSelection("/user/supervisor/start"); var counter = 0; Console.WriteLine("Node 1 started..."); Console.WriteLine("Press [ESC] to stop, [L] 1k messages, [H] for 10k, [M] for 100k or any other key to send a single message"); while (true) { ConsoleKeyInfo result = Console.ReadKey(); if (result.Key == ConsoleKey.Escape) { break; } switch (result.Key) { case ConsoleKey.L: { counter = TransmitMessageManyTimes(counter, startActor, 1000); break; } case ConsoleKey.H: { counter = TransmitMessageManyTimes(counter, startActor, 10000); break; } case ConsoleKey.M: { counter = TransmitMessageManyTimes(counter, startActor, 100000); break; } default: { counter = TransmitMessageManyTimes(counter, startActor, 1); break; } } //actor.Tell(new AuditMessage("Hi - " + counter.ToString())); } Console.ReadKey(); }
public static void CreaContexto() { ActorSystem = ActorSystem.Create("SistemaPanelComentario"); //Actores.PanelComentarioControlador = // ActorSystem.ActorSelection("akka.tcp://[email protected]:8091/user/PanelComentarioControlador") // .ResolveOne(TimeSpan.FromSeconds(3)) // .Result; Actores.CuentaAhorroControlador = ActorSystem.ActorSelection("akka.tcp://[email protected]:8091/user/CuentaAhorroControlador") .ResolveOne(TimeSpan.FromSeconds(3)) .Result; //Actores.PanelRespuestaControlador = ActorSystem.ActorOf<PanelRespuestaActor>(); Actores.CuentaAhorroRespuestaControlador = ActorSystem.ActorOf<CuentaAhorroActorLocal>(); }
private async static Task TestHelloWorld(ActorSystem serverSystem, ActorSystem clientSystem) { Console.WriteLine("\n*** HelloWorld ***"); var serverActor = serverSystem.ActorOf<HelloWorldActor>("actor"); var clientActor = clientSystem.ActorSelection("akka.tcp://Server@localhost:9001/user/actor").ResolveOne(TimeSpan.Zero).Result; var helloWorld = clientActor.Cast<HelloWorldRef>(); Console.WriteLine(await helloWorld.SayHello("World")); Console.WriteLine(await helloWorld.SayHello("Dlrow")); try { Console.WriteLine(await helloWorld.SayHello("")); } catch (Exception e) { Console.WriteLine("!EXCEPTION! " + e.GetType().Name + " " + e.Message); } Console.WriteLine(await helloWorld.GetHelloCount()); }
private static void Ping(ActorSystem actorSystem, string[] commandArgs) { actorSystem.ActorSelection($"akka.tcp://[email protected]:{commandArgs[1]}/user/ping") .Ask<string>("ping") .ContinueWith(x => { if (x.IsFaulted) { Console.WriteLine("Got faulty ping response: " + x.Exception?.ToString()); } else { Console.WriteLine("Got ping response: " + x.Result); } }); }
static void Main(string[] args) { //var builder = new ContainerBuilder(); //builder.RegisterType<StatsCooridnator>(); //builder.RegisterType<StatsBook>(); //var container = builder.Build(); _system = ActorSystem.Create("akkaStats", ConfigurationFactory.Load()); MongoDbPersistence.Instance.Apply(_system); _system.ActorOf(Props.Create<StatsManagerActor>(), "StatsManager"); ShortPause(); //_statsCollecter = _system.ActorOf(_system.DI().Props<StatsCooridnator>(), "StatsCooridnator"); Console.WriteLine("Akka Stat Runner {0}", _system.Name); var message0 = new PlayerMessage(PlayerEvent.Add, 1, "Eric Chavez", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 4, AtBatResult.SacFly)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message0); var message1 = new PlayerMessage(PlayerEvent.Add, 1, "Eric Chavez", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 3, AtBatResult.Hit)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message1); var message2 = new PlayerMessage(PlayerEvent.Add, 2, "Barry Bonds", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 55, AtBatResult.Walk)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message2); var message3 = new PlayerMessage(PlayerEvent.Add, 3, "Will Clark", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 5, AtBatResult.Out)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message3); var message4 = new PlayerMessage(PlayerEvent.Add, 1, "Eric Chavez", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 12, AtBatResult.Out)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message4); var message5 = new PlayerMessage(PlayerEvent.Get, 1, "Eric Chavez", null); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message5); var message6 = new PlayerMessage(PlayerEvent.Add, 1, "Eric Chavez", new AtBatRecord(Guid.NewGuid(), DateTime.UtcNow, 23, AtBatResult.Hit)); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message6); var message7 = new PlayerMessage(PlayerEvent.Get, 1, "Eric Chavez", null); _system.ActorSelection("/user/StatsManager/PlayerCoordinator").Tell(message7); //_system.Shutdown(); //_system.AwaitTermination(); Console.ReadLine(); }
public void Setup(BenchmarkContext context) { _remoteMessageThroughput = context.GetCounter(RemoteMessageCounterName); System1 = ActorSystem.Create("SystemA" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemA" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _echo = System1.ActorOf(Props.Create(() => new EchoActor()), "echo"); System2 = ActorSystem.Create("SystemB" + ActorSystemNameCounter.Next(), CreateActorSystemConfig("SystemB" + ActorSystemNameCounter.Current, "127.0.0.1", 0)); _receiver = System2.ActorOf( Props.Create(() => new BenchmarkActor(_remoteMessageThroughput, RemoteMessageCount, _resetEvent)), "benchmark"); var system1Address = RARP.For(System1).Provider.Transport.DefaultAddress; var system2Address = RARP.For(System2).Provider.Transport.DefaultAddress; var system1EchoActorPath = new RootActorPath(system1Address) / "user" / "echo"; var system2RemoteActorPath = new RootActorPath(system2Address) / "user" / "benchmark"; // set the timeout high here to avoid timeouts // TL;DR; - on slow machines it can take longer than 2 seconds to form the association, do the handshake, and reply back // using the in-memory transport. _remoteReceiver = System1.ActorSelection(system2RemoteActorPath).ResolveOne(TimeSpan.FromSeconds(30)).Result; _remoteEcho = System2.ActorSelection(system1EchoActorPath).ResolveOne(TimeSpan.FromSeconds(2)).Result; }
private static void Unwatch(ActorSystem actorSystem, string[] commandArgs) { var resolveOne = actorSystem.ActorSelection("user/watcher" + commandArgs[1]).ResolveOne(TimeSpan.FromSeconds(1)); resolveOne.ContinueWith(task => { if (task.IsFaulted) { Console.WriteLine("Could not find watcher" + commandArgs[1]); return; } resolveOne.Result.Tell(PoisonPill.Instance); }); }
static FrontActorSystem() { System = ActorSystem.Create("TaxiSystem"); SignalRActor = System.ActorOf(Props.Create(() => new PresentingActor())); Presenter = System.ActorSelection("akka.tcp://TaxiBackend@localhost:8080/user/presenter"); }
private async static Task TestSurrogate(ActorSystem serverSystem, ActorSystem clientSystem) { Console.WriteLine("\n*** Surrogate ***"); var serverActor = serverSystem.ActorOf<SurrogateActor>("surrogate"); var clientActor = clientSystem.ActorSelection("akka.tcp://Server@localhost:9001/user/surrogate").ResolveOne(TimeSpan.Zero).Result; var surrogate = clientActor.Cast<SurrogateRef>(); Console.WriteLine(await surrogate.GetPath(clientActor.Path)); Console.WriteLine(await surrogate.GetAddress(clientActor.Path.Address)); Console.WriteLine(((SurrogateRef)await surrogate.GetSelf()).CastToIActorRef().Path); }
private async static Task TestPedantic(ActorSystem serverSystem, ActorSystem clientSystem) { Console.WriteLine("\n*** Pedantic ***"); var serverActor = serverSystem.ActorOf<PedanticActor>("pedantic"); var clientActor = clientSystem.ActorSelection("akka.tcp://Server@localhost:9001/user/pedantic").ResolveOne(TimeSpan.Zero).Result; var pedantic = clientActor.Cast<PedanticRef>(); await pedantic.TestCall(); Console.WriteLine(await pedantic.TestOptional(null)); Console.WriteLine(await pedantic.TestOptional(1)); Console.WriteLine(await pedantic.TestTuple(Tuple.Create(1, "One"))); Console.WriteLine(await pedantic.TestParams(1, 2, 3)); Console.WriteLine(await pedantic.TestPassClass(new TestParam { Name = "Mouse", Price = 10 })); Console.WriteLine(await pedantic.TestReturnClass(1, 2)); }