public void CatchUp(long from)
        {
            var reader = new PostgresqlJournalReader(_memstateSettings);

            while (true)
            {
                var lastRecordId = from;

                var records = reader.GetRecords(lastRecordId);

                foreach (var record in records)
                {
                    lastRecordId = record.RecordNumber;

                    try
                    {
                        _handler(record);
                    }
                    catch (Exception exception)
                    {
                        _log.LogError(exception, $"Exception occured in {GetType().Name}.CatchUp");
                    }
                }

                lock (Lock)
                {
                    if (_buffer.TryPeek(out var queuedRecord))
                    {
                        if (queuedRecord.RecordNumber <= lastRecordId)
                        {
                            // Caught up
                            while (_buffer.TryDequeue(out queuedRecord))
                            {
                                try
                                {
                                    _handler(queuedRecord);
                                }
                                catch (Exception exception)
                                {
                                    _log.LogError(exception, $"Exception occured in {GetType().Name}.CatchUp");
                                }
                            }
                        }
                    }
                    else
                    {
                        _ready = true;

                        return;
                    }
                }
            }
        }
        public PostgresqlJournalSubscription(PostgresqlSettings settings, Action <JournalRecord> handler, long nextRecordId)
        {
            Ensure.NotNull(settings, nameof(settings));

            _settings     = settings;
            _handler      = handler;
            _nextRecordId = nextRecordId;

            _journalReader = new PostgresqlJournalReader(settings);

            _listenerThread = new Thread(Listen)
            {
                Name = "Memstate:Postgresql:NotificationsListener"
            };

            _readerThread = new Thread(Reader)
            {
                Name = "Memstate:Postgresql:Reader"
            };
        }