Exemplo n.º 1
0
 public AkkaClient()
 {
     _system           = ActorSystem.Create(SystemConfigurationHelper.ClusterName, SystemConfigurationHelper.GetConfig(0, Role));
     _automaticCluster = new AutomaticCluster(_system);
     _automaticCluster.Join();
     TargetServer = ClusterSharding.Get(_system).StartProxy(
         typeName: "stuffer",
         role: null,
         messageExtractor: GetMessageExtractor());
 }
Exemplo n.º 2
0
        public AkkaServer(int port)
        {
            _system           = ActorSystem.Create(SystemConfigurationHelper.ClusterName, SystemConfigurationHelper.GetConfig(port, Role));
            _automaticCluster = new AutomaticCluster(_system);
            _automaticCluster.Join();

            var sharding    = ClusterSharding.Get(_system);
            var shardRegion = sharding.Start(
                typeName: "stuffer",
                entityProps: Props.Create <PersistentStuffActor>(),
                settings: ClusterShardingSettings.Create(_system).WithRole(Role),
                messageExtractor: GetMessageExtractor());
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            using (var system = ActorSystem.Create("sharded-cluster-system", ConfigurationFactory.Load().WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();

                    RunExample(system);

                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }
Exemplo n.º 4
0
        static void Main(string[] args)
        {
            using (var system = ActorSystem.Create("sharded-cluster-system", Cch2.Cfg.WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();
                    CounterHelper.CounterActor = system.ActorOf(Props.Create(() => new CounterActor()));


                    RunExample(system);

                    Console.WriteLine("## Is started");
                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            Config config = @"
            akka {
              actor {
                provider = cluster
                serializers {
                  hyperion = ""Akka.Serialization.HyperionSerializer, Akka.Serialization.Hyperion""
                }
                serialization-bindings {
                  ""System.Object"" = hyperion
                }
              }
              remote {
                dot-netty.tcp {
                  public-hostname = ""localhost""
                  hostname = ""localhost""
                  port = 0
                }
              }
              cluster {
                auto-down-unreachable-after = 5s
                sharding {
                  least-shard-allocation-strategy.rebalance-threshold = 3
                }
              }
              persistence {
                journal {
                  plugin = ""akka.persistence.journal.sqlite""
                  sqlite {
                    connection-string = ""Datasource=store.db""
                    auto-initialize = true
                  }
                }
                snapshot-store {
                  plugin = ""akka.persistence.snapshot-store.sqlite""
                  sqlite {
                    connection-string = ""Datasource=store.db""
                    auto-initialize = true
                  }
                }
              }
            }";

            using (var system = ActorSystem.Create("sharded-cluster-system", config.WithFallback(ClusterSingletonManager.DefaultConfig())))
            {
                var automaticCluster = new AutomaticCluster(system);
                try
                {
                    automaticCluster.Join();

                    RunExample(system);

                    Console.ReadLine();
                }
                finally
                {
                    //WARNING: you may need to remove SQLite database file from bin/Debug or bin/Release in case when unexpected crash happened
                    automaticCluster.Leave();
                }
            }
        }