Exemplo n.º 1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            var roles   = Environment.GetEnvironmentVariable("CLUSTER_ROLES");
            var envName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");

            SystemNameForCluster = Environment.GetEnvironmentVariable("ACTORSYSTEM");

            var akkaConfig  = AkkaLoadEx.Load(envName);
            var actorSystem = ActorSystem.Create(SystemNameForCluster, akkaConfig);

            AkkaLoadEx.RegisterActor(
                "ClusterWorkerPoolActor",
                actorSystem.ActorOf(Props.Create <WorkActor>()
                                    .WithRouter(FromConfig.Instance),
                                    "cluster-workerpool"
                                    ));



            if (roles.Contains("AdminNode"))
            {
                string singleToneRole = "AdminNode";
                actorSystem.BootstrapSingleton <SingleToneActor>("SingleToneActor", singleToneRole);
                var singleToneActor = actorSystem.BootstrapSingletonProxy("SingleToneActor", singleToneRole, "/user/SingleToneActor", "singleToneActorProxy");
                AkkaLoadEx.RegisterActor("SingleToneActor", singleToneActor);

                actorSystem
                .Scheduler
                .ScheduleTellRepeatedly(TimeSpan.FromSeconds(1),
                                        TimeSpan.FromSeconds(1),
                                        singleToneActor, "이벤트 발생..", ActorRefs.NoSender);
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public SingleToneActor()
        {
            logger.Debug("Create SingleToneActor");

            ReceiveAsync <string>(async msg =>
            {
                logger.Debug($"SingleToneActor:{msg}");

                AkkaLoadEx.ActorSelect("ClusterWorkerPoolActor").Tell("Task");
            });
        }