public MqttSubscriberService(
     EmailProcessor processor,
     ILogger <MqttSubscriberService> logger,
     IMqttClientServiceOptions serviceOptions,
     IMqttClientOptions clientOptions)
 {
     _processor      = processor ?? throw new ArgumentNullException(nameof(processor));
     _logger         = logger ?? throw new ArgumentNullException(nameof(logger));
     _clientOptions  = clientOptions ?? throw new ArgumentNullException(nameof(clientOptions));
     _serviceOptions = serviceOptions ?? throw new ArgumentNullException(nameof(serviceOptions));
 }
        public static async Task ProcessRequestAsync(this EmailProcessor processor, HttpContext context)
        {
            PubSubRequest    req;
            EmailMessageTask entry;

            try
            {
                req = await JsonSerializer.DeserializeAsync <PubSubRequest>(context.Request.Body, requestSerializerOptions, context.RequestAborted);

                entry = JsonSerializer.Deserialize <EmailMessageTask>(Convert.FromBase64String(req.Message.Data), entrySerializerOptions);
            }
            catch (Exception exn)
            {
                processor.Logger.LogError(exn, "Failed to deserializer pub/sub request message.");
                context.Response.StatusCode = 204; // Message should not be retried...
                return;
            }
            context.Response.StatusCode = await processor.ProcessAsync(entry, req.Message.MessageId, context.RequestAborted);

            return;
        }