static void Main(string[] args)
        {
            var akkaConfigSection = ((AkkaConfigurationSection)ConfigurationManager.GetSection("akka")).AkkaConfig;
            var actorSystem       = ActorSystem.Create("AkkaSingleton", akkaConfigSection);

            var worker1 = actorSystem.ActorOf(WorkerActor.CreateProps("1"), "worker1");
            var worker2 = actorSystem.ActorOf(WorkerActor.CreateProps("2"), "worker2");
            var worker3 = actorSystem.ActorOf(WorkerActor.CreateProps("3"), "worker3");

            var singletonActorRef = actorSystem.ActorOf(ClusterSingletonManager.Props(
                                                            singletonProps: ManagerSingletonActor.CreateProps("1"),
                                                            terminationMessage: PoisonPill.Instance,
                                                            settings: ClusterSingletonManagerSettings.Create(actorSystem).WithSingletonName("singleton").WithRole("singletons")),
                                                        name: "ClusterSingletonManager");

            Console.ReadLine();
        }
コード例 #2
0
 protected override void PreStart()
 {
     Worker = Context.System.ActorOf(WorkerActor.Props(), nameof(WorkerActor));
     Context.System.Scheduler.ScheduleTellRepeatedly(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(1), Worker, "Hello", Self);
     base.PreStart();
 }