public ProcessingService(ILogger <ProcessingService> logger, ChannelReader <MqttApplicationMessage> channelReader, IHubContext <DataHub, IDataHub> hubContext, MqttReceiverService mqttReceiverService, HildebrandStateStore store) { Logger = logger; ChannelReader = channelReader; HubContext = hubContext; MqttReceiverService = mqttReceiverService; Store = store; }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { await MqttReceiverService.StartAsync(stoppingToken); await foreach (var message in ChannelReader.ReadAllAsync(stoppingToken)) { try { await HandleMessageAsync(message); } catch (Exception ex) { Logger.LogWarning(ex, "Error handling payload: {Exception}", ex.Message); } } }