Пример #1
0
 private void ProcessSupervision(SuperviseThisAccount command)
 {
     this.Monitor();
     if (!_accounts.ContainsKey(command.AccountNumber))
     {
         AccountAddedToSupervision @event = AddThisAccountToState(command.AccountNumber);
         Persist(@event, s =>
         {
             var address = InstantiateThisAccount(command.AccountNumber);
         });
         ApplySnapShotStrategy();
     }
     else
     {
         _log.Info($"You tried to load account {command.AccountNumber} which has already been loaded");
     }
 }
Пример #2
0
        private void ProcessSupervision(SuperviseThisAccount command)
        {
            Monitor();

            var account = new AccountUnderSupervision(command.AccountNumber, command.CurrentAccountBalance);
            var @event  = new AccountAddedToSupervision(command.AccountNumber, (decimal)command.CurrentAccountBalance);

            Persist(@event, s =>
            {
                _stopWatch = Stopwatch.StartNew();
                _stopWatch.Start();

                account.AccountActorRef = InstantiateThisAccount(account);
                _porfolioState.SupervizedAccounts.AddOrSet(command.AccountNumber, account);

                //Self.Tell(new PublishPortfolioStateToKafka());

                _stopWatch.Stop();

                ReportStopwatchInfo($"ProcessSupervision()/Persist()", _stopWatch.ElapsedMilliseconds);

                ApplySnapShotStrategy();
            });
        }