ServiceConnect.Core.ExpiredTimeoutsPoller.InnerPoll C# (CSharp) Метод

InnerPoll() приватный Метод

private InnerPoll ( CancellationToken cancellationToken ) : void
cancellationToken System.Threading.CancellationToken
Результат void
        internal void InnerPoll(CancellationToken cancellationToken)
        {
            var utcNow = DateTime.UtcNow;

            if (NextQueryUtc > utcNow || cancellationToken.IsCancellationRequested)
            {
                return;
            }

            // connect to the data store and get all the expired timeouts
            TimeoutsBatch timeoutsBatch = _processManagerFinder.GetTimeoutsBatch();

            foreach (var timeoutData in timeoutsBatch.DueTimeouts)
            {
                if (cancellationToken.IsCancellationRequested)
                {
                    return;
                }

                // dispatch the timeout message
                var timeoutMsg = new TimeoutMessage(timeoutData.ProcessManagerId);
                _bus.Send(timeoutData.Destination, timeoutMsg);

                // remove dispatch timeout
                _processManagerFinder.RemoveDispatchedTimeout(timeoutData.Id);
            }

            lock (_locker)
            {
                var nextQueryTime = timeoutsBatch.NextQueryTime;

                // ensure to poll at least every minute
                var maxNextQuery = utcNow.AddMinutes(1);

                NextQueryUtc = (nextQueryTime > maxNextQuery) ? maxNextQuery : nextQueryTime;

                Logger.DebugFormat("Polling next query is at {0}.", NextQueryUtc.ToLocalTime());
            }
        }
    }

Usage Example

        public void TestDispatchedTimeoutMessageIsRemoved()
        {
            // Arrange
            SetupProcessManagerFinderMock(DateTime.UtcNow.AddSeconds(30));
            var expiredTimeoutsPoller = new ExpiredTimeoutsPoller(_mockBus.Object);

            // Act
            expiredTimeoutsPoller.InnerPoll(new CancellationToken(false));

            // Assert
            _mockProcessManagerFinder.Verify(i => i.RemoveDispatchedTimeout(_tdId), Times.Once);
        }
All Usage Examples Of ServiceConnect.Core.ExpiredTimeoutsPoller::InnerPoll