예제 #1
0
        public MailInActor(IActorRef commander)
        {
            this.commander = commander;

            Receive <CheckMail>(m =>
            {
                Console.Write("[MailInActor        ]: Checking e-mail inbox ...");

                var ex = Helpers.GetRandomInt(CalcConfig.NetworkExceptionChance);
                if (ex == 2)
                {
                    throw new SocketException();
                }

                ex = Helpers.GetRandomInt(CalcConfig.FatalExceptionChance);
                if (ex == 5)
                {
                    throw new ArgumentNullException();
                }

                // emulate receiving n e-mails
                int n = Helpers.GetRandomInt(CalcConfig.MaxNumberEmailsReceived);
                Console.WriteLine(" {0} e-mails found.", n);

                for (int i = 0; i < n; i++)
                {
                    var from             = Helpers.GetRandomEmail();
                    var loanId           = Helpers.GetRandomLoadId();
                    var calculationOrder = new CalculateLoan(from, loanId);
                    this.commander.Tell(calculationOrder);
                }
            });
        }
예제 #2
0
 public void Handle(CalculateLoan message)
 {
     if (_coordinators.Any())
     {
         _coordinators[_button].Tell(message);
         _button = _button + 1;
         _button = _button % _coordinators.Count;
     }
 }