Пример #1
0
        async Task KeepPolling(PullStrategy strategy = PullStrategy.KeepPulling, int?waitTimeSeconds = 10)
        {
            var queueIsEmpty = false;

            do
            {
                try { queueIsEmpty = !await Poll(waitTimeSeconds); }
                catch (Exception exception) { Log.For <Subscriber>().Error(exception); }
            }while (strategy == PullStrategy.KeepPulling || !queueIsEmpty);
        }
Пример #2
0
        async Task KeepPolling(PullStrategy strategy = PullStrategy.KeepPulling, int waitTimeSeconds = 10)
        {
            await Task.Run(() => { });

            Poll(waitTimeSeconds);
            //var queueIsEmpty = false;
            //do
            //{
            //try { queueIsEmpty = !await Poll(waitTimeSeconds); }
            //catch (Exception exception) { Log.For<Subscriber>().Error(exception); }
            //}
            //while (strategy == PullStrategy.KeepPulling || !queueIsEmpty);
        }
Пример #3
0
        public Puller(string subject, string consumerGroup, bool isBroadcast, TagType tagType, string[] tags, ConsumeMode consumeMode, PullController controller, PullStrategy pullStrategy, LoadBalance loadBalance)
        {
            _subject       = subject;
            _originSubject = RetrySubjectUtils.RealSubject(_subject);
            _consumerGroup = consumerGroup;
            _isBroadcast   = isBroadcast;
            _consumeMode   = consumeMode;
            _tagType       = (_tags == null || _tags.Length == 0) ? (byte)0 : (byte)tagType;
            _tags          = tags;

            _controller = controller;

            _pullStrategy = pullStrategy;
            _loadBalance  = loadBalance;
        }
Пример #4
0
        async Task KeepPolling(PullStrategy strategy = PullStrategy.KeepPulling)
        {
            var queueIsEmpty = false;

            do
            {
                try
                {
                    queueIsEmpty = (await Poll() == false);
                }
                catch (Exception exception)
                {
                    Log.For <Subscriber>().Error(exception);
                }
            }while (strategy == PullStrategy.KeepPulling || !queueIsEmpty);
        }
Пример #5
0
        async Task RunHandler(PullStrategy strategy = PullStrategy.KeepPulling)
        {
            do
            {
                using (await SyncLock.Lock())
                    if (await HandleNext())
                    {
                        continue;
                    }

                if (strategy == PullStrategy.KeepPulling)
                {
                    Thread.Sleep(5000);
                }
                else
                {
                    break;
                }
            }while (true);
        }