public async Task HandleApplicationMessageReceivedAsync(MqttApplicationMessageReceivedEventArgs eventArgs)
        {
            try
            {
                if (_logger.IsEnabled(LogLevel.Debug))
                {
                    _logger.LogDebug("Received payload: {{ {0} }}.", string.Join(", ", eventArgs.ApplicationMessage.Payload.Select(b => "0x" + b.ToString("X2"))));
                }
                var entry  = JsonSerializer.Deserialize <EmailMessageTask>(eventArgs.ApplicationMessage.Payload, _serviceOptions.JsonSerializerOptions);
                var status = await _processor.ProcessAsync(entry, "<none>", CancellationToken.None);

                eventArgs.ProcessingFailed = status >= 400;
            }
            catch (Exception exn)
            {
                _logger.LogError(exn, "Failed to process entry.");
                eventArgs.ProcessingFailed = true;
            }
        }
        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;
        }