示例#1
0
        private static void Run()
        {
            var config = ConfigurationFactory.ParseString(@"
	            akka {
		            actor.provider = cluster
                    remote.dot-netty.tcp {
                        hostname = ""127.0.0.1""
                        port = 0
                    }
		            cluster.discovery {
			            provider = akka.cluster.discovery.consul
			            consul {
				            listener-url = ""http://127.0.0.1:8500""
		                    refresh-interval = 1m
			            }
		            }
	            }"    );

            using (var system = ActorSystem.Create("sample", config))
            {
                ClusterDiscovery.Join(system);

                system.ActorOf(Props.Create <SampleActor>());
                Console.ReadLine();
            }
        }
        public override Task StartAsync(CancellationToken cancellationToken)
        {
            cluster = Akka.Cluster.Cluster.Get(ActorSystem);

            cluster.RegisterOnMemberUp(RegisterOnMemberUp);

            cluster.RegisterOnMemberRemoved(RegisterOnMemberRemoved);

            ClusterDiscovery.Join(ActorSystem);

            return(base.StartAsync(cancellationToken));
        }