public ResourceProviderMessageProcessorHostedService(
     IOptions <MessageProcessorOptions> options,
     IOptions <MessageBusOptions> busOptions,
     IServiceScopeFactory serviceScopeFactory,
     ILoggerFactory loggerFactory,
     IAzureADTokenService keyVaultService
     )
 {
     this.loggerFactory       = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
     this.options             = options?.Value ?? throw new ArgumentNullException(nameof(options));
     this.keyVaultService     = keyVaultService ?? throw new ArgumentNullException(nameof(keyVaultService));
     this.busOptions          = busOptions?.Value ?? throw new ArgumentNullException(nameof(busOptions));
     this.serviceScopeFactory = serviceScopeFactory ?? throw new ArgumentNullException(nameof(serviceScopeFactory));
     this.logger = loggerFactory.CreateLogger <ResourceProviderMessageProcessorHostedService>();
 }
Пример #2
0
        public MessageBus(IOptions <MessageBusOptions> options, IAzureADTokenService keyVaultService, ILoggerFactory loggerFactory, IMessageBusCorrelationFactory[] correlations)
        {
            this.options         = options?.Value ?? throw new ArgumentNullException(nameof(options));
            this.keyVaultService = keyVaultService ?? throw new ArgumentNullException(nameof(keyVaultService));
            this.loggerFactory   = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));
            this.correlations    = correlations ?? throw new ArgumentNullException(nameof(correlations));

            bus = new AsyncLazy <ServiceBusMessageProcessorClientProvider>((Func <Task <ServiceBusMessageProcessorClientProvider> >)Factory);
            bus.Start();

            _pipeline = new ActionBlock <ProviderMessage>(async(message) =>
            {
                var sender = await bus;

                await sender.SendMessageAsync(message);
            }, new ExecutionDataflowBlockOptions {
                MaxDegreeOfParallelism = 4
            });
        }