예제 #1
0
파일: Program.cs 프로젝트: vonwenm/akka.net
        private static void WithHashPool()
        {
            IUnityContainer container = new UnityContainer();

            container.RegisterType <TypedWorker>();


            using (var system = ActorSystem.Create("MySystem"))
            {
                var propsResolver =
                    new UnityDependencyResolver(container, system);

                var router = system.ActorOf(propsResolver.Create <TypedWorker>().WithRouter(FromConfig.Instance), "router1");

                Task.Delay(500).Wait();
                Console.WriteLine("Sending Messages");

                for (var i = 0; i < 5; i++)
                {
                    for (var j = 0; j < 7; j++)
                    {
                        var msg = new TypedActorMessage {
                            Id = j, Name = Guid.NewGuid().ToString()
                        };
                        var ms = new AnotherMessage {
                            Id = j, Name = msg.Name
                        };

                        var envelope = new ConsistentHashableEnvelope(ms, msg.Id);

                        router.Tell(msg);
                        router.Tell(envelope);
                    }
                }
            }


            Console.ReadLine();
        }
예제 #2
0
 public void Handle(AnotherMessage message)
 {
     Console.WriteLine("{0} received other {1}", Self.Path.Name, message);
 }