public NonNullConverterValueBinder(IStorageQueue queue, IConverter <TInput, IStorageQueueMessage> converter, IMessageEnqueuedWatcher messageEnqueuedWatcher) { _queue = queue; _converter = converter; _messageEnqueuedWatcher = messageEnqueuedWatcher; }
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); }
private async Task RegisterWithSharedBlobListenerAsync( string hostId, SharedBlobListener sharedBlobListener, BlobServiceClient blobClient, QueueClient hostBlobTriggerQueue, IMessageEnqueuedWatcher messageEnqueuedWatcher, CancellationToken cancellationToken) { BlobTriggerExecutor triggerExecutor = new BlobTriggerExecutor(hostId, _functionDescriptor, _input, new BlobReceiptManager(blobClient), new BlobTriggerQueueWriter(hostBlobTriggerQueue, messageEnqueuedWatcher), _loggerFactory.CreateLogger <BlobListener>()); await sharedBlobListener.RegisterAsync(blobClient, _container, triggerExecutor, cancellationToken).ConfigureAwait(false); }
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); }
private async Task RegisterWithSharedBlobListenerAsync( string hostId, SharedBlobListener sharedBlobListener, IStorageBlobClient blobClient, IStorageQueue hostBlobTriggerQueue, IMessageEnqueuedWatcher messageEnqueuedWatcher, CancellationToken cancellationToken) { BlobTriggerExecutor triggerExecutor = new BlobTriggerExecutor(hostId, _functionId, _input, BlobETagReader.Instance, new BlobReceiptManager(blobClient), new BlobTriggerQueueWriter(hostBlobTriggerQueue, messageEnqueuedWatcher)); await sharedBlobListener.RegisterAsync(_container, triggerExecutor, cancellationToken); }
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; }
internal static void RegisterSharedWatcherWithQueueProcessor(QueueProcessor queueProcessor, IMessageEnqueuedWatcher sharedWatcher) { if (sharedWatcher != null) { EventHandler <PoisonMessageEventArgs> poisonMessageEventHandler = (object sender, PoisonMessageEventArgs e) => { sharedWatcher.Notify(e.PoisonQueue.Name); }; queueProcessor.MessageAddedToPoisonQueue += poisonMessageEventHandler; } }
private async Task<IListener> CreateBlobDiscoveryToQueueMessageListenerAsync(string hostId, SharedBlobListener sharedBlobListener, IStorageBlobClient blobClient, IStorageQueue hostBlobTriggerQueue, IMessageEnqueuedWatcher messageEnqueuedWatcher, CancellationToken cancellationToken) { BlobTriggerExecutor triggerExecutor = new BlobTriggerExecutor(hostId, _functionId, _input, BlobETagReader.Instance, new BlobReceiptManager(blobClient), new BlobTriggerQueueWriter(hostBlobTriggerQueue, messageEnqueuedWatcher)); await sharedBlobListener.RegisterAsync(_container, triggerExecutor, cancellationToken); return new BlobListener(sharedBlobListener); }
public QueueAsyncCollector(QueueClient queue, IMessageEnqueuedWatcher messageEnqueuedWatcher) { this._queue = queue; this._messageEnqueuedWatcher = messageEnqueuedWatcher; }
internal static QueueProcessor CreateQueueProcessor(QueueClient queue, QueueClient poisonQueue, ILoggerFactory loggerFactory, IQueueProcessorFactory queueProcessorFactory, QueuesOptions queuesOptions, IMessageEnqueuedWatcher sharedWatcher) { QueueProcessorOptions context = new QueueProcessorOptions(queue, loggerFactory, queuesOptions, poisonQueue); QueueProcessor queueProcessor = null; if (HostQueueNames.IsHostQueue(queue.Name)) { // We only delegate to the processor factory for application queues, // not our built in control queues queueProcessor = new QueueProcessor(context); } else { queueProcessor = queueProcessorFactory.Create(context); } QueueListener.RegisterSharedWatcherWithQueueProcessor(queueProcessor, sharedWatcher); return(queueProcessor); }
public BlobTriggerQueueWriter(IStorageQueue queue, IMessageEnqueuedWatcher watcher) { _queue = queue; Debug.Assert(watcher != null); _watcher = watcher; }
internal SharedQueueWriter(IStorageQueue queue, IMessageEnqueuedWatcher watcher) { _queue = queue; Debug.Assert(watcher != null); _watcher = watcher; }
internal static void RegisterSharedWatcherWithQueueProcessor(QueueProcessor queueProcessor, IMessageEnqueuedWatcher sharedWatcher) { if (sharedWatcher != null) { queueProcessor.MessageAddedToPoisonQueueAsync += (queueProcessor, e) => { sharedWatcher.Notify(e.PoisonQueue.Name); return(Task.CompletedTask); }; } }
public QueueListener(QueueClient queue, QueueClient poisonQueue, ITriggerExecutor <QueueMessage> triggerExecutor, IWebJobsExceptionHandler exceptionHandler, ILoggerFactory loggerFactory, SharedQueueWatcher sharedWatcher, QueuesOptions queueOptions, QueueProcessor queueProcessor, FunctionDescriptor functionDescriptor, string functionId = null, TimeSpan?maxPollingInterval = null) { if (queueOptions == null) { throw new ArgumentNullException(nameof(queueOptions)); } if (queueProcessor == null) { throw new ArgumentNullException(nameof(queueProcessor)); } 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; } _queueProcessor = queueProcessor; TimeSpan maximumInterval = _queueProcessor.QueuesOptions.MaxPollingInterval; if (maxPollingInterval.HasValue && maximumInterval > maxPollingInterval.Value) { // enforce the maximum polling interval if specified maximumInterval = maxPollingInterval.Value; } _delayStrategy = new RandomizedExponentialBackoffStrategy(QueuePollingIntervals.Minimum, maximumInterval); _scaleMonitorDescriptor = new ScaleMonitorDescriptor($"{_functionId}-QueueTrigger-{_queue.Name}".ToLower(CultureInfo.InvariantCulture)); _shutdownCancellationTokenSource = new CancellationTokenSource(); }
public BlobTriggerQueueWriter(QueueClient queue, IMessageEnqueuedWatcher watcher) { _queue = queue; Debug.Assert(watcher != null); _watcher = watcher; }
public QueueAsyncCollector(IStorageQueue queue, IMessageEnqueuedWatcher messageEnqueuedWatcher) { this._queue = queue; this._messageEnqueuedWatcher = messageEnqueuedWatcher; }