public QueueSupervisor(StatelessServiceContext context, IServiceBusService serviceBusService) : base(context) { _serviceBusService = serviceBusService ?? throw new ArgumentNullException(nameof(serviceBusService)); ServiceEventSource.Current.ServiceMessage(this.Context, "New Stateless Supervisor Created", _serviceBusService); _serviceBusService.Register(ProcessMessageAsync, new MessageHandlerOptions(MessageExceptionRecievedAsync)); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { _serviceBusService.Register(ProcessMessageAsync, new MessageHandlerOptions(MessageExceptionRecievedAsync) { MaxConcurrentCalls = 100 }); while (!stoppingToken.IsCancellationRequested) { _logger.LogInformation($"Worker running at: {DateTimeOffset.Now}. Processed {_count} messages"); await Task.Delay(1000, stoppingToken); } }