public IListener CreateQueueListenr( string queue, string poisonQueue, Func <string, CancellationToken, Task <FunctionResult> > callback ) { // Provide an upper bound on the maximum polling interval for run/abort from dashboard. // This ensures that if users have customized this value the Dashboard will remain responsive. TimeSpan maxPollingInterval = QueuePollingIntervals.DefaultMaximum; var wrapper = new Wrapper { _callback = callback }; var queueClient = Convert(queue); var poisonQueueClient = Convert(poisonQueue); var queueProcessor = new QueueProcessor(new QueueProcessorOptions(queueClient, _loggerFactory, _queueOptions, poisonQueueClient)); QueueListener.RegisterSharedWatcherWithQueueProcessor(queueProcessor, _sharedWatcher); IListener listener = new QueueListener(queueClient, poisonQueue: poisonQueueClient, triggerExecutor: wrapper, exceptionHandler: _exceptionHandler, loggerFactory: _loggerFactory, sharedWatcher: _sharedWatcher, queueOptions: _queueOptions, queueProcessor: queueProcessor, functionDescriptor: new FunctionDescriptor { Id = SharedLoadBalancerQueueListenerFunctionId }, maxPollingInterval: maxPollingInterval); return(listener); }
public SharedBlobQueueListener Create() { BlobQueueTriggerExecutor triggerExecutor = new BlobQueueTriggerExecutor(_blobWrittenWatcher, _loggerFactory.CreateLogger <BlobListener>()); // The poison queue to use for a given poison blob lives in the same // storage account as the triggering blob by default. In multi-storage account scenarios // that means that we'll be writing to different poison queues, determined by // the triggering blob. // However we use a poison queue in the host storage account as a fallback default // in case a particular blob lives in a restricted "blob only" storage account (i.e. no queues). var defaultPoisonQueue = _hostQueueServiceClient.GetQueueClient(HostQueueNames.BlobTriggerPoisonQueue); // This special queue bypasses the QueueProcessorFactory - we don't want people to override this. // So we define our own custom queue processor factory for this listener var queueProcessor = new SharedBlobQueueProcessor(triggerExecutor, _hostBlobTriggerQueue, defaultPoisonQueue, _loggerFactory, _queueOptions); QueueListener.RegisterSharedWatcherWithQueueProcessor(queueProcessor, _sharedQueueWatcher); IListener listener = new QueueListener(_hostBlobTriggerQueue, defaultPoisonQueue, triggerExecutor, _exceptionHandler, _loggerFactory, _sharedQueueWatcher, _queueOptions, queueProcessor, _functionDescriptor, functionId: SharedBlobQueueListenerFunctionId); return(new SharedBlobQueueListener(listener, triggerExecutor)); }
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); }