public SharedBlobQueueListener Create() { IStorageQueue blobTriggerPoisonQueue = _queueClient.GetQueueReference(HostQueueNames.BlobTriggerPoisonQueue); BlobQueueTriggerExecutor triggerExecutor = new BlobQueueTriggerExecutor(_blobWrittenWatcher); IDelayStrategy delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, _queueConfiguration.MaxPollingInterval); IListener listener = new QueueListener(_hostBlobTriggerQueue, blobTriggerPoisonQueue, triggerExecutor, delayStrategy, _exceptionHandler, _trace, _sharedQueueWatcher, _queueConfiguration); return(new SharedBlobQueueListener(listener, triggerExecutor)); }
public Task <IListener> CreateAsync(IFunctionExecutor executor, CancellationToken cancellationToken) { QueueTriggerExecutor triggerExecutor = new QueueTriggerExecutor(_instanceFactory, executor); IDelayStrategy delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, _queueConfiguration.MaxPollingInterval); SharedQueueWatcher sharedWatcher = _sharedContextProvider.GetOrCreate <SharedQueueWatcher>( new SharedQueueWatcherFactory(_messageEnqueuedWatcherSetter)); IListener listener = new QueueListener(_queue, _poisonQueue, triggerExecutor, delayStrategy, _backgroundExceptionDispatcher, _log, sharedWatcher, _queueConfiguration.BatchSize, _queueConfiguration.MaxDequeueCount); return(Task.FromResult(listener)); }
public Task <IListener> CreateAsync(CancellationToken cancellationToken) { QueueTriggerExecutor triggerExecutor = new QueueTriggerExecutor(_executor); IDelayStrategy delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, _queueConfiguration.MaxPollingInterval); SharedQueueWatcher sharedWatcher = _sharedContextProvider.GetOrCreateInstance <SharedQueueWatcher>( new SharedQueueWatcherFactory(_messageEnqueuedWatcherSetter)); IListener listener = new QueueListener(_queue, _poisonQueue, triggerExecutor, delayStrategy, _exceptionHandler, _trace, sharedWatcher, _queueConfiguration); return(Task.FromResult(listener)); }
public Task <IListener> CreateAsync(IFunctionExecutor executor, CancellationToken cancellationToken) { ITriggerExecutor <IStorageQueueMessage> triggerExecutor = new HostMessageExecutor(executor, _functionLookup, _functionInstanceLogger); TimeSpan configuredMaximum = _queueConfiguration.MaxPollingInterval; // Provide an upper bound on the maximum polling interval for run/abort from dashboard. // Use the default maximum for host polling (1 minute) unless the configured overall maximum is even faster. TimeSpan maximum = configuredMaximum < DefaultMaximum ? configuredMaximum : DefaultMaximum; IDelayStrategy delayStrategy = new RandomizedExponentialBackoffStrategy(Minimum, maximum); IListener listener = new QueueListener(_queue, poisonQueue: null, triggerExecutor: triggerExecutor, delayStrategy: delayStrategy, backgroundExceptionDispatcher: _backgroundExceptionDispatcher, log: _log, sharedWatcher: null, batchSize: _queueConfiguration.BatchSize, maxDequeueCount: _queueConfiguration.MaxDequeueCount); return(Task.FromResult(listener)); }
public async Task RetryStartWithBackoffAsync(CancellationToken cancellationToken) { var backoffStrategy = new RandomizedExponentialBackoffStrategy(_minRetryInterval, _maxRetryInterval); int attempt = 0; string message; while (!_started && !cancellationToken.IsCancellationRequested) { var delay = backoffStrategy.GetNextDelay(false); await Task.Delay(delay, cancellationToken); if (!cancellationToken.IsCancellationRequested) { message = $"Retrying to start listener for function '{_descriptor.ShortName}' (Attempt {++attempt})"; _logger?.LogInformation(message); await StartAsync(cancellationToken, allowRetry : false); if (_started) { message = $"Listener successfully started for function '{_descriptor.ShortName}' after {attempt} retries."; _logger?.LogInformation(message); if (cancellationToken.IsCancellationRequested) { // stop has been called while we were in the process of starting // so we need to stop this listener await StopAsync(cancellationToken); message = $"Listener for function '{_descriptor.ShortName}' stopped. A stop was initiated while starting."; _logger?.LogInformation(message); } } } } }
public BackoffPollingHelper(TimeSpan minimumInterval, TimeSpan maximumInterval) { this.backoffStrategy = new RandomizedExponentialBackoffStrategy(minimumInterval, maximumInterval); this.resetEvent = new AsyncAutoResetEvent(signaled: false); }