Ejemplo n.º 1
0
 public void ReturnCustomerDataField(CustomerFindRequest request)
 {
     Sender.Tell(new CustomerFindResponse
     {
         Cached = true,
         Data   = _customerData
     });
 }
Ejemplo n.º 2
0
        public void FindCustomerData(CustomerFindRequest request)
        {
            var actorRef = Context.Child(request.Name);

            if (actorRef is Nobody)
            {
                actorRef = Context.ActorOf <CustomerCache>(request.Name);
            }
            actorRef.Forward(request);
        }
Ejemplo n.º 3
0
        public async Task FetchCustomerDataFromService(CustomerFindRequest request)
        {
            _customerData = await new CustomerService().Find(request.Name);

            Sender.Tell(new CustomerFindResponse
            {
                Cached = false,
                Data   = _customerData
            });

            // Kill actor 1 minute in the future
            // and with that effectively purging the cached data
            Context.System.Scheduler
            .ScheduleTellOnce(TimeSpan.FromMinutes(1), Self, PoisonPill.Instance, Self);
        }