protected override void OnReceive(object message) { switch (message) { case TempReadingMessage m: if (m.ContainerId != ContainerId) { return; } // check temp reading _monitor.Check(new Reading(new Temp(m.Reading), m.Timestamp)); // persist the aggregate TempRangeMonitorRepo.SaveAsync(_monitor); // emit any events EventDispatcher.DispatchAsync(_monitor.Events).Wait(); break; default: break; } }
protected override void PreStart() { // rehydrate the aggregate _monitor = TempRangeMonitorRepo.GetAsync(new ContainerId(ContainerId)).Result; }