예제 #1
0
        private static void LoadConfigFromAppConfig()
        {
            var system = ActorSystem.Create("mySys");

            var helloActor  = system.ActorOf(HelloActor.Props(), "hello");
            var helloActor1 = system.ActorOf(HelloActor.Props(), "hello1");

            helloActor.Tell(new Who("Johnny"));
        }
예제 #2
0
        private static void RoundRobinBroadcast()
        {
            var system = ActorSystem.Create("mySys");

            var router = system.ActorOf(HelloActor.Props().WithRouter(FromConfig.Instance), "hello");

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                router.Tell(new Who("Johnny"));
            }
        }
예제 #3
0
        private static void LoadConfigFromParsing()
        {
            var config = ConfigurationFactory.ParseString(
                @"
my-dispatcher {
    type = Dispatcher
    throughput = 100
    throughput-deadline-time = 0ms
}");
            var system = ActorSystem.Create("mySys", config);

            var helloActor = system.ActorOf(HelloActor.Props().WithDispatcher("my-dispatcher"), "hello");

            helloActor.Tell(new Who("Johnny"));
        }
예제 #4
0
        private static void RoundRobinGroup()
        {
            var system = ActorSystem.Create("mySys");

            system.ActorOf(HelloActor.Props(), "hello");
            system.ActorOf(HelloActor.Props(), "hello1");

            var workers = new[] { "/user/hello", "/user/hello1" };

            var router = system.ActorOf(Props.Empty.WithRouter(new RoundRobinGroup(workers)), "hello-group");

            while (Console.ReadKey().Key != ConsoleKey.Escape)
            {
                router.Tell(new Who("Johnny"));
            }
        }
예제 #5
0
        private static void UseResizer()
        {
            var system = ActorSystem.Create("mySys");

            var router = system.ActorOf(HelloActor.Props().WithRouter(FromConfig.Instance), "hello");

            var random = new Random(Guid.NewGuid().GetHashCode());

            while (true)
            {
                Parallel.For(0, random.Next(1000), i => { router.Tell(new Who("Johnny")); });

                System.Threading.Thread.Sleep(random.Next(10000));

                Console.Clear();
            }
        }