示例#1
0
        public LoanDataChangeProcessor(ILogger logger, ISerializer serializer, ProducerConfig producerConfig, ConsumerConfig consumerConfig, string connectionString, int pollIntervalInSeconds = 10)
        {
            if (string.IsNullOrWhiteSpace(connectionString))
            {
                throw new ArgumentException("message", nameof(connectionString));
            }
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));

            loanDataChangeDetector = new LoanDataChangeDetector(logger, connectionString);
            loanDataChangeDetector.PublishLoanDeletedEvent += LoanChangeDetector_PublishLoanDeletedEvent;
            loanDataChangeDetector.PublishLoanUpsertEvent  += LoanChangeDetector_PublishLoanUpsertEvent;
            loanDataChangePublisher = new LoanDataChangePublisher(logger, serializer, producerConfig, consumerConfig);

            timer           = new System.Timers.Timer(PollIntervalInSeconds * 1000);
            timer.AutoReset = true;
            timer.Elapsed  += Timer_Tick;

            this.PollIntervalInSeconds = pollIntervalInSeconds;
        }
示例#2
0
        protected virtual void Dispose(bool disposing)
        {
            if (!disposedValue)
            {
                if (disposing)
                {
                    Stop();

                    loanDataChangeDetector.PublishLoanDeletedEvent -= LoanChangeDetector_PublishLoanDeletedEvent;
                    loanDataChangeDetector.PublishLoanUpsertEvent  -= LoanChangeDetector_PublishLoanUpsertEvent;

                    loanDataChangeDetector = null;
                    loanDataChangePublisher.Dispose();
                    changeDetectionProcessWaitHandle.Dispose();
                }

                disposedValue = true;
            }
        }