private void Processing() { Receive <IPriceUpdate>(p => { _history = _history.WithPrice(p); _log.Info("[{0}] - current price is [{1}] as of [{2}]", _history.StockId, p.CurrentAvgPrice, p.Timestamp); }); Receive <GetPriceHistory>(h => { Sender.Tell(_history); }); Receive <GetLatestPrice>(_ => { Sender.Tell(_history.CurrentPriceUpdate); }); Receive <PriceAndVolumeSnapshot>(_ => { }); // ignore // purge older price update entries. Receive <Prune>(_ => { _history = _history.Prune(DateTimeOffset.UtcNow.AddMinutes(-5)); }); Receive <Terminated>(t => { if (t.ActorRef.Equals(_tickerEntity)) { _log.Info("Source of truth entity terminated. Re-acquiring..."); Context.SetReceiveTimeout(TimeSpan.FromSeconds(5)); _priceActorGateway.Tell(new FetchPriceAndVolume(_tickerSymbol)); _mediator.Tell(new Unsubscribe(_priceTopic, Self)); // unsubscribe until we acquire new source of truth pricing Become(WaitingForPriceAndVolume); } }); }