public QueueListener(IStorageQueue queue, IStorageQueue poisonQueue, ITriggerExecutor <IStorageQueueMessage> triggerExecutor, IWebJobsExceptionHandler exceptionHandler, ILoggerFactory loggerFactory, SharedQueueWatcher sharedWatcher, IQueueConfiguration queueConfiguration, QueueProcessor queueProcessor = null, TimeSpan?maxPollingInterval = null) { if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (queueConfiguration.BatchSize <= 0) { throw new ArgumentException("BatchSize must be greater than zero."); } if (queueConfiguration.MaxDequeueCount <= 0) { throw new ArgumentException("MaxDequeueCount must be greater than zero."); } _timer = new TaskSeriesTimer(this, exceptionHandler, Task.Delay(0)); _queue = queue; _poisonQueue = poisonQueue; _triggerExecutor = triggerExecutor; _exceptionHandler = exceptionHandler; _queueConfiguration = queueConfiguration; // if the function runs longer than this, the invisibility will be updated // on a timer periodically for the duration of the function execution _visibilityTimeout = TimeSpan.FromMinutes(10); if (sharedWatcher != null) { // Call Notify whenever a function adds a message to this queue. sharedWatcher.Register(queue.Name, this); _sharedWatcher = sharedWatcher; } EventHandler <PoisonMessageEventArgs> poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler <PoisonMessageEventArgs>)null; _queueProcessor = queueProcessor ?? CreateQueueProcessor( _queue.SdkObject, _poisonQueue != null ? _poisonQueue.SdkObject : null, loggerFactory, _queueConfiguration, poisonMessageEventHandler); TimeSpan maximumInterval = _queueProcessor.MaxPollingInterval; if (maxPollingInterval.HasValue && maximumInterval > maxPollingInterval.Value) { // enforce the maximum polling interval if specified maximumInterval = maxPollingInterval.Value; } _delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, maximumInterval); }
public QueueListener(IStorageQueue queue, IStorageQueue poisonQueue, ITriggerExecutor <IStorageQueueMessage> triggerExecutor, IDelayStrategy delayStrategy, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, TraceWriter trace, SharedQueueWatcher sharedWatcher, IQueueConfiguration queueConfiguration) { if (trace == null) { throw new ArgumentNullException("trace"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (queueConfiguration.BatchSize <= 0) { throw new ArgumentException("BatchSize must be greater than zero."); } if (queueConfiguration.MaxDequeueCount <= 0) { throw new ArgumentException("MaxDequeueCount must be greater than zero."); } _timer = new TaskSeriesTimer(this, backgroundExceptionDispatcher, Task.Delay(0)); _queue = queue; _poisonQueue = poisonQueue; _triggerExecutor = triggerExecutor; _delayStrategy = delayStrategy; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _trace = trace; _queueConfiguration = queueConfiguration; if (sharedWatcher != null) { // Call Notify whenever a function adds a message to this queue. sharedWatcher.Register(queue.Name, this); _sharedWatcher = sharedWatcher; } EventHandler poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler)null; _queueProcessor = CreateQueueProcessor( _queue.SdkObject, _poisonQueue != null ? _poisonQueue.SdkObject : null, _trace, _queueConfiguration, poisonMessageEventHandler); }
public QueueListener(IStorageQueue queue, IStorageQueue poisonQueue, ITriggerExecutor<IStorageQueueMessage> triggerExecutor, IDelayStrategy delayStrategy, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, TraceWriter trace, SharedQueueWatcher sharedWatcher, IQueueConfiguration queueConfiguration) { if (trace == null) { throw new ArgumentNullException("trace"); } if (queueConfiguration == null) { throw new ArgumentNullException("queueConfiguration"); } if (queueConfiguration.BatchSize <= 0) { throw new ArgumentException("BatchSize must be greater than zero."); } if (queueConfiguration.MaxDequeueCount <= 0) { throw new ArgumentException("MaxDequeueCount must be greater than zero."); } _timer = new TaskSeriesTimer(this, backgroundExceptionDispatcher, Task.Delay(0)); _queue = queue; _poisonQueue = poisonQueue; _triggerExecutor = triggerExecutor; _delayStrategy = delayStrategy; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _trace = trace; _queueConfiguration = queueConfiguration; if (sharedWatcher != null) { // Call Notify whenever a function adds a message to this queue. sharedWatcher.Register(queue.Name, this); _sharedWatcher = sharedWatcher; } EventHandler poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler)null; _queueProcessor = CreateQueueProcessor( _queue.SdkObject, _poisonQueue != null ? _poisonQueue.SdkObject : null, _trace, _queueConfiguration, poisonMessageEventHandler); }
public QueueListener(IStorageQueue queue, IStorageQueue poisonQueue, ITriggerExecutor <IStorageQueueMessage> triggerExecutor, IDelayStrategy delayStrategy, IBackgroundExceptionDispatcher backgroundExceptionDispatcher, TextWriter log, SharedQueueWatcher sharedWatcher, int batchSize, int maxDequeueCount) { if (log == null) { throw new ArgumentNullException("log"); } if (batchSize <= 0) { throw new ArgumentOutOfRangeException("batchSize"); } if (maxDequeueCount <= 0) { throw new ArgumentOutOfRangeException("maxDequeueCount"); } _timer = new TaskSeriesTimer(this, backgroundExceptionDispatcher, Task.Delay(0)); _queue = queue; _poisonQueue = poisonQueue; _triggerExecutor = triggerExecutor; _delayStrategy = delayStrategy; _backgroundExceptionDispatcher = backgroundExceptionDispatcher; _log = log; if (sharedWatcher != null) { // Call Notify whenever a function adds a message to this queue. sharedWatcher.Register(queue.Name, this); _sharedWatcher = sharedWatcher; } _batchSize = batchSize; _newBatchThreshold = (uint)_batchSize / 2; _maxDequeueCount = (uint)maxDequeueCount; }
public QueueListener(QueueClient queue, QueueClient poisonQueue, ITriggerExecutor <QueueMessage> triggerExecutor, IWebJobsExceptionHandler exceptionHandler, ILoggerFactory loggerFactory, SharedQueueWatcher sharedWatcher, QueuesOptions queueOptions, IQueueProcessorFactory queueProcessorFactory, FunctionDescriptor functionDescriptor, string functionId = null, TimeSpan?maxPollingInterval = null) { if (queueOptions == null) { throw new ArgumentNullException(nameof(queueOptions)); } if (queueProcessorFactory == null) { throw new ArgumentNullException(nameof(queueProcessorFactory)); } if (loggerFactory == null) { throw new ArgumentNullException(nameof(loggerFactory)); } if (queueOptions.BatchSize <= 0) { throw new ArgumentException("BatchSize must be greater than zero."); } if (queueOptions.MaxDequeueCount <= 0) { throw new ArgumentException("MaxDequeueCount must be greater than zero."); } _timer = new TaskSeriesTimer(this, exceptionHandler, Task.Delay(0)); _queue = queue; _poisonQueue = poisonQueue; _triggerExecutor = triggerExecutor; _exceptionHandler = exceptionHandler; _queueOptions = queueOptions; _logger = loggerFactory.CreateLogger <QueueListener>(); _functionDescriptor = functionDescriptor ?? throw new ArgumentNullException(nameof(functionDescriptor)); _functionId = functionId ?? _functionDescriptor.Id; // if the function runs longer than this, the invisibility will be updated // on a timer periodically for the duration of the function execution _visibilityTimeout = TimeSpan.FromMinutes(10); if (sharedWatcher != null) { // Call Notify whenever a function adds a message to this queue. sharedWatcher.Register(queue.Name, this); _sharedWatcher = sharedWatcher; } EventHandler <PoisonMessageEventArgs> poisonMessageEventHandler = _sharedWatcher != null ? OnMessageAddedToPoisonQueue : (EventHandler <PoisonMessageEventArgs>)null; _queueProcessor = CreateQueueProcessor(_queue, _poisonQueue, loggerFactory, queueProcessorFactory, _queueOptions, poisonMessageEventHandler); TimeSpan maximumInterval = _queueProcessor.MaxPollingInterval; if (maxPollingInterval.HasValue && maximumInterval > maxPollingInterval.Value) { // enforce the maximum polling interval if specified maximumInterval = maxPollingInterval.Value; } _delayStrategy = new RandomizedExponentialBackoffStrategy(SharedQueuePollingIntervals.Minimum, maximumInterval); _scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{_functionId}-QueueTrigger-{_queue.Name}".ToLower(CultureInfo.InvariantCulture)); _shutdownCancellationTokenSource = new CancellationTokenSource(); }