private IActorRef InstantiateThisAccount(AccountUnderSupervision account) { var accountActor = Context.ActorOf(Props.Create <AccountActor>(), account.AccountNumber); account.AccountActorRef = accountActor; // is this needed? _log.Debug($"Instantiated account {accountActor.Path.Name}"); return(accountActor); }
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(); }); }