private static void InitSystem(int port) { var serverOptions = (new RpcServerOptions()) .UsingIPAddress("127.0.0.1") .UsingPort(port); var manager = new RpcManager(serverOptions); manager.Start(); var systemOptions = ActorSystemOptions .UsingName("system-2") .UsingErrorHandler( (actorSys, error) => { Console.WriteLine(error); }, (actorSys, process, msg, error) => { Console.WriteLine(error); }); var actorSystem = ActorSystem.GetOrAdd(systemOptions); manager.Bind(actorSystem); var remoteActorOptions = ActorOptions .UsingName("system-1-actor-1") .UsingRemoteActorSystem("system-1") .UsingRemoteEndPoint("127.0.0.1", 17777); actorSystem.FromRemote(remoteActorOptions); }
private static void RunRemoteSystem() { var serverOptions = (new RpcServerOptions()) .UsingIPAddress("127.0.0.1") .UsingPort(remotePort); var manager = new RpcManager(serverOptions); manager.Start(); var systemOptions = ActorSystemOptions .UsingName(remoteSystem) .UsingErrorHandler( (actorSys, error) => { Console.WriteLine(error); }, (actorSys, process, msg, error) => { Console.WriteLine(error); }); var actorSystem = ActorSystem.GetOrAdd(systemOptions); manager.Bind(actorSystem); var actorOptions = ActorOptions .UsingName(remoteActor); var Completed = Task.FromResult(0); var sw = new Stopwatch(); var pid = actorSystem.FromFunction((ctx, message) => { var count = Interlocked.Increment(ref counter); if (count == 1) { sw.Restart(); } else { if (count % 1000 == 0) { Console.WriteLine(count); } if (count == loop) { Interlocked.Exchange(ref counter, 0); sw.Stop(); Console.WriteLine("Ellapsed time: " + sw.ElapsedMilliseconds); Console.WriteLine("Concurrency: " + (loop * 1000 / sw.ElapsedMilliseconds) + " call per sec"); } } if (message.MessageType == MessageType.FutureMessage) { ctx.RespondTo(message, "world " + count.ToString("000000")); } return(Completed); }, actorOptions); }