public void Process(NonBlockingChannel statusChannel,
                            ITaskable uiTask)
        {
            var inboundChannel = new NonBlockingChannel();
            var baristaOutboundChannel = new EnumerableChannel<IMessage>();
            var customerOutboundChannel = new EnumerableChannel<IMessage>();
            var registerOutboundChannel = new EnumerableChannel<IMessage>();
            var abandonedMessages = new NonBlockingChannel();

            var messageRouter = new OrderingProcessMessageRouter(
                inboundChannel,
                baristaOutboundChannel,
                customerOutboundChannel,
                registerOutboundChannel,
                abandonedMessages,
                statusChannel);

            var baristaActor = new BaristaActor(inboundChannel, baristaOutboundChannel);
            var customerActor = new CustomerActor(inboundChannel, customerOutboundChannel);
            var registerActor = new RegisterActor(inboundChannel, registerOutboundChannel);

            //ThreadPool.QueueUserWorkItem(x => messageRouter.Process());
            //ThreadPool.QueueUserWorkItem(x => baristaActor.Process());
            //ThreadPool.QueueUserWorkItem(x => customerActor.Process());
            //ThreadPool.QueueUserWorkItem(x => registerActor.Process());
            //ThreadPool.QueueUserWorkItem(x => uiTask.Process());

            new Thread(messageRouter.Process).Start();
            new Thread(baristaActor.Process).Start();
            new Thread(customerActor.Process).Start();
            new Thread(registerActor.Process).Start();
            new Thread(uiTask.Process).Start();
        }
Example #2
0
        private async Task <IActorRef> GetOrCreateCustomer(int id)
        {
            string name = CustomerActor.CreateName(id);

            try
            {
                return(await _actorSystem.ActorSelection($"akka://AkkaWeb/user/" + CustomerActor.CreateName(id))
                       .ResolveOne(TimeSpan.FromMilliseconds(250)));
            }
            catch (ActorNotFoundException)
            {
                return(_actorSystem.ActorOf(Props.Create(() => new CustomerActor(id, _bank)), name));
            }
        }