Пример #1
0
        /// <summary>
        /// Creates all required actors, which host partitions.
        /// </summary>
        /// <param name="config"></param>
        public ActorSbDistributedDictionaryBase(ActorSbConfig config, ILogger logger)
        {
            if (config == null)
            {
                throw new ArgumentException("Configuration must be specified.");
            }

            this.Config = config;

            this.actorSystem = new ActorSystem("HtmCalculusDriver", config, logger);
        }
Пример #2
0
        public void TellTest()
        {
            Debug.WriteLine($"Start of {nameof(TellTest)}");

            var         cfg       = GetLocaSysConfig();
            ActorSystem sysLocal  = new AkkaSb.Net.ActorSystem($"{nameof(TellTest)}/local", cfg);
            ActorSystem sysRemote = new ActorSystem($"{nameof(TellTest)}/remote", GetRemoteSysConfig());

            CancellationTokenSource src = new CancellationTokenSource();

            var task = Task.Run(() =>
            {
                sysRemote.Start(src.Token);
            });

            ActorReference actorRef1 = sysLocal.CreateActor <MyActor>(1);

            actorRef1.Tell("message 1").Wait();

            actorRef1.Tell(new TestClass()).Wait();

            ActorReference actorRef2 = sysLocal.CreateActor <MyActor>(2);

            actorRef2.Tell("message 2").Wait();

            while (true)
            {
                if (receivedMessages.Count == 3)
                {
                    Assert.IsTrue(receivedMessages.Values.Contains("message 1"));
                    Assert.IsTrue(receivedMessages.Values.Contains("message 2"));
                    Assert.IsTrue(receivedMessages.Values.Contains("UnitTestsProject.SbAkkaTest+TestClass"));
                    src.Cancel();
                    break;
                }
                Thread.Sleep(250);
            }

            task.Wait();

            Debug.WriteLine($"End of {nameof(TellTest)}");
        }
        public void Start(string[] args)
        {
            ActorSbConfig cfg = new ActorSbConfig();

            var builder = new ConfigurationBuilder();

            builder.AddCommandLine(args);
            builder.AddEnvironmentVariables();
            IConfigurationRoot configArgs = builder.Build();

            cfg.SbConnStr                  = configArgs["SbConnStr"];
            cfg.ReplyMsgQueue              = configArgs["ReplyMsgQueue"];
            cfg.RequestMsgTopic            = configArgs["RequestMsgTopic"];
            cfg.TblStoragePersistenConnStr = configArgs["TblStoragePersistenConnStr"];
            cfg.ActorSystemName            = configArgs["ActorSystemName"];
            cfg.RequestSubscriptionName    = configArgs["SubscriptionName"];
            string systemName = configArgs["SystemName"];

            Console.CancelKeyPress += (sender, eventArgs) =>
            {
                tokenSrc.Cancel();
            };

            BlobStoragePersistenceProvider prov = null;

            if (String.IsNullOrEmpty(cfg.TblStoragePersistenConnStr) == false)
            {
                prov = new BlobStoragePersistenceProvider();
            }

            prov.InitializeAsync(cfg.ActorSystemName, new Dictionary <string, object>()
            {
                { "StorageConnectionString", cfg.TblStoragePersistenConnStr }
            }, purgeOnStart: false, logger: this.logger).Wait();

            akkaClusterSystem = new AkkaSb.Net.ActorSystem($"{systemName}", cfg, logger, prov);
            akkaClusterSystem.Start(tokenSrc.Token);

            Console.WriteLine("Press any key to stop Actor SB system.");
        }