Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure functions azure队列中的消息消失_Azure Functions_Azure Queues - Fatal编程技术网

Azure functions azure队列中的消息消失

Azure functions azure队列中的消息消失,azure-functions,azure-queues,Azure Functions,Azure Queues,我希望这里有人能对我现在已经遇到过两次的问题有一点了解。 我有一个ERP系统,在该系统中创建发票,当这些发票准备好发送时,我通过cron计划作业将它们传输到我们的发票系统。当它们从开票系统发送到最终客户时,它会向azure http触发器函数触发一个webhook,该函数将消息(invoiceId)放入队列中。然后,我有一个队列触发器,它将拾取这些信息并更新我们的ERP系统,以便发票不再被更改。这在90%的情况下都很有效 上周,我们向发票系统发送了12张发票,我们的簿记员将这些发票发送给客户。

我希望这里有人能对我现在已经遇到过两次的问题有一点了解。 我有一个ERP系统,在该系统中创建发票,当这些发票准备好发送时,我通过cron计划作业将它们传输到我们的发票系统。当它们从开票系统发送到最终客户时,它会向azure http触发器函数触发一个webhook,该函数将消息(invoiceId)放入队列中。然后,我有一个队列触发器,它将拾取这些信息并更新我们的ERP系统,以便发票不再被更改。这在90%的情况下都很有效

上周,我们向发票系统发送了12张发票,我们的簿记员将这些发票发送给客户。 今天早上检查时,其中两个未在我们的ERP系统中更新为“已发送”状态。 因此,我检查了队列触发器,可以看到没有对所讨论的两个发票进行调用(在函数->监视器下)。所以我检查了毒药队列,它既不存在也不在真正的队列中。最后,我检查了Http触发器调用,我可以看到有一个对两个发票的调用,并且我有一个日志,它将正确记录的消息放入队列,没有错误

因此,让我感到奇怪的是,对于其他10张发票,这一切都很顺利,没有遗漏任何东西。但对于这两个人来说,队列消息似乎消失了。有人有什么想法吗

共享我的两个功能,用于添加到队列和更新我们的ERP系统

HttpTrigger

[FunctionName(nameof(InvoiceBooked))]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)]
            HttpRequest req, ILogger log)
        {
            try
            {
                log.LogInformation("Invoice Booked from VS. C# HTTP trigger function processed a request.");
                string invoiceBookedId = req.Query["invoiceId"];
                log.LogInformation($"Invoice Booked. RequestBody: {invoiceBookedId}");

                if (string.IsNullOrEmpty(invoiceBookedId))
                {
                    log.LogError("Invoice Booked. Query was empty");
                    return new BadRequestResult();
                }

                // Get the connection string from app settings
                var storageAccountName = System.Environment.GetEnvironmentVariable("StorageAccountName", EnvironmentVariableTarget.Process);
                var storageAccountKey = System.Environment.GetEnvironmentVariable("StorageAccountKey", EnvironmentVariableTarget.Process);
                string connectionString =
                    $"DefaultEndpointsProtocol=https;AccountName={storageAccountName};AccountKey={storageAccountKey};EndpointSuffix=core.windows.net";

                // Instantiate a QueueClient which will be used to create and manipulate the queue
                var queueClient = new QueueClient(connectionString, AzureConstants.InvoiceBookedQueueName);

                // Create the queue
                await queueClient.CreateIfNotExistsAsync();
                log.LogInformation($"Invoice Booked. Enqueuing message: {invoiceBookedId}");
                if (await queueClient.ExistsAsync())
                {
                    var messageBase64 = System.Convert.ToBase64String(
                        System.Text.Encoding.UTF8.GetBytes(invoiceBookedId));

                    // Send a message to the queue
                    await queueClient.SendMessageAsync(messageBase64);

                    log.LogInformation($"Invoice Booked. Message enqueued: {invoiceBookedId}");
                }
            }
            catch (Exception e)
            {
                log.LogError(e, "Invoice Booked. Error when enqueueing booked invoice");
            }

            return (ActionResult)new OkResult();
        }

我似乎发现了一些额外的信息。由于某些原因,作业宿主有时会停止。我今天注意到,我在手动输入一些消失了的ID,一些通过了,但一个又消失了。在跟踪日志中,我可以看到,就在它应该获取队列项的时候,作业主机被停止了。让我感到奇怪的是,消息是出列的,根本没有关于这一点的日志。如果在消息启动时将其放入队列,则一切正常。有人有什么想法吗?我已经添加了日志供您查看


日志文件可以在这里下载:

我似乎找到了一些其他信息。由于某些原因,作业宿主有时会停止。我今天注意到,我在手动输入一些消失了的ID,一些通过了,但一个又消失了。在跟踪日志中,我可以看到,就在它应该获取队列项的时候,作业主机被停止了。让我感到奇怪的是,消息是出列的,根本没有关于这一点的日志。如果在消息启动时将其放入队列,则一切正常。有人有什么想法吗?我已经添加了日志供您查看
[FunctionName(nameof(InvoiceBookedQueueTrigger))]
        public static void Run([QueueTrigger(AzureConstants.InvoiceBookedQueueName, Connection = "QueueStorage")]string queueItem, ILogger log)
        {
            log.LogInformation($"InvoiceBookedQueueTrigger. C# Queue trigger function processed: {queueItem}");

            var erpService = new ERPService(log, System.Environment.GetEnvironmentVariable("APIKey", EnvironmentVariableTarget.Process));

            int.TryParse(queueItem, out var invoiceId);

            log.LogInformation($"invoiceId is: {invoiceId}");

            var success = erpService.SetInvoiceBooked(invoiceId);

            if(!success)
                throw new WebException("There was a problem updating the invoice in erp");
            
        }