Esempio n. 1
0
        private static AzureStorageQueueWorkerOptions <TMessageProcessor> CreateAzureStorageQueueWorkerOptions <TMessage, TMessageProcessor>(
            IServiceProvider applicationServiceProvider,
            Action <IServiceProvider, AzureStorageQueueWorkerOptionsBuilder> optionsAction)
            where TMessageProcessor : IMessageProcessor <TMessage>
        {
            var options = new AzureStorageQueueWorkerOptions <TMessageProcessor>();
            var builder = new AzureStorageQueueWorkerOptionsBuilder(options);

            optionsAction?.Invoke(applicationServiceProvider, builder);

            try
            {
                options.Validate();
            }
            catch (Exception ex)
            {
                var logger = applicationServiceProvider
                             .GetRequiredService <ILogger <AzureStorageQueueWorker <TMessage, TMessageProcessor> > >();
                logger.SetupExceptionOccurred(
                    ex,
                    "Missed required settings setup exception was caught. MessageProcessor {Processor}",
                    typeof(TMessageProcessor).FullName);
                throw;
            }

            return(options);
        }
Esempio n. 2
0
 public ExceptionHandler(
     ILogger logger,
     AzureStorageQueueWorkerOptions workerOptions,
     IServiceProvider serviceProvider,
     IHostApplicationLifetime hostApplicationLifetime)
 {
     _logger                  = logger;
     _workerOptions           = workerOptions;
     _serviceProvider         = serviceProvider;
     _hostApplicationLifetime = hostApplicationLifetime;
 }
Esempio n. 3
0
 public AzureStorageQueueWorker(
     ILogger <AzureStorageQueueWorker <TMessage, TMessageProcessor> > logger,
     IServiceProvider serviceProvider,
     IHostApplicationLifetime hostApplicationLifetime,
     AzureStorageQueueWorkerOptions <TMessageProcessor> workerOptions,
     TelemetryClient telemetryClient)
 {
     _logger           = logger;
     _workerOptions    = workerOptions;
     _exceptionHandler = new ExceptionHandler(logger, workerOptions, serviceProvider, hostApplicationLifetime);
     _telemetryClient  = telemetryClient;
     _serviceProvider  = serviceProvider;
 }
Esempio n. 4
0
 public QueueMessageProcessor(
     ILogger logger,
     QueueClient queueClient,
     IServiceProvider serviceProvider,
     ExceptionHandler exceptionHandler,
     AzureStorageQueueWorkerOptions <TMessageProcessor> workerOptions,
     TelemetryClient telemetryClient)
 {
     _logger              = logger;
     _queueClient         = queueClient;
     _workerOptions       = workerOptions;
     _serviceProvider     = serviceProvider;
     _exceptionHandler    = exceptionHandler;
     _deleteMessagePolicy = GetDeleteMessagePolicy("Message deletion from a queue \"{queueName}\" failed #{retryAttempt}");
     _updateMessagePolicy = GetDeleteMessagePolicy("Message update in a queue \"{queueName}\" failed #{retryAttempt}");
     _telemetryClient     = telemetryClient;
 }