public ReadingPersistenceActor(Guid deviceId)
        {
            _deviceId = deviceId;

            Command <NormalizedMeterReading>(HandleNormalizeMeterReadingCommand);
            Command <RequestLastNormalizedReadings>(HandleRequestLastNormalizedReading);
            Command <TakeHourlySnapshotMessage>(_ => TakeHourlySnapshot());
            Command <WrittenReadingsToDatabase>(HandleWrittenReadingsToDatabaseCommand);

            Recover <SnapshotOffer>(HandleSnapshotOffer);
            Recover <NormalizedMeterReading>(HandleNormalizeMeterReading);
            Recover <WrittenReadingsToDatabase>(HandleWrittenReadingsToDatabase);

            _dbWriterActor = Context.ActorOf(ReadingDbWriterActor.CreateProps(_deviceId));

            ScheduleSnapshots();
        }
        public ReadingPersistenceActor(Guid deviceId)
        {
            _deviceId = deviceId;

            // 2. Commands are message tha com in from the normal mailbox
            Command <NormalizedMeterReading>(HandleNormalizeMeterReadingCommand);
            Command <RequestLastNormalizedReadings>(HandleRequestLastNormalizedReading);
            Command <TakeHourlySnapshotMessage>(_ => TakeHourlySnapshot());
            Command <WrittenReadingsToDatabase>(HandleWrittenReadingsToDatabaseCommand);

            // 3. Recover messages are replayed first when the Actor is restored (after a restart)
            Recover <SnapshotOffer>(HandleSnapshotOffer);
            Recover <NormalizedMeterReading>(HandleNormalizeMeterReading);
            Recover <WrittenReadingsToDatabase>(HandleWrittenReadingsToDatabase);

            // 4. This child Actor will save older data to another database for future reference
            _dbWriterActor = Context.ActorOf(ReadingDbWriterActor.CreateProps(_deviceId));

            // 5. Schedule an hourly message at a random time point during the hour.
            ScheduleSnapshots();
        }