コード例 #1
0
        private void TryPushingMessagesToClients()
        {
            lock (_lock)
            {
                if (_state == PersistentSubscriptionState.NotReady)
                {
                    return;
                }

                while (true)
                {
                    OutstandingMessage message;
                    if (!_streamBuffer.TryPeek(out message))
                    {
                        return;
                    }
                    if (_pushClients.PushMessageToClient(message.ResolvedEvent) == ConsumerPushResult.NoMoreCapacity)
                    {
                        return;
                    }
                    if (!_streamBuffer.TryDequeue(out message))
                    {
                        throw new WTFException(
                                  "This should never happen. Something is very wrong in the threading model.");
                    }
                    if (message.ResolvedEvent.OriginalEventNumber > _lastKnownMessage)
                    {
                        _lastKnownMessage = message.ResolvedEvent.OriginalEventNumber;
                    }
                    MarkBeginProcessing(message);
                }
            }
        }
コード例 #2
0
        private void TryPushingMessagesToClients()
        {
            lock (_lock)
            {
                if (_state == PersistentSubscriptionState.NotReady)
                {
                    return;
                }

                foreach (StreamBuffer.OutstandingMessagePointer messagePointer in _streamBuffer.Scan())
                {
                    OutstandingMessage message = messagePointer.Message;
                    ConsumerPushResult result  = _pushClients.PushMessageToClient(message.ResolvedEvent, message.RetryCount);
                    if (result == ConsumerPushResult.Sent)
                    {
                        messagePointer.MarkSent();
                        MarkBeginProcessing(message);
                        _lastKnownMessage = Math.Max(_lastKnownMessage, message.ResolvedEvent.OriginalEventNumber);
                    }
                    else if (result == ConsumerPushResult.Skipped)
                    {
                        // The consumer strategy skipped the message so leave it in the buffer and continue.
                    }
                    else if (result == ConsumerPushResult.NoMoreCapacity)
                    {
                        return;
                    }
                }
            }
        }