• <tfoot id='Is8RE'></tfoot>

      <i id='Is8RE'><tr id='Is8RE'><dt id='Is8RE'><q id='Is8RE'><span id='Is8RE'><b id='Is8RE'><form id='Is8RE'><ins id='Is8RE'></ins><ul id='Is8RE'></ul><sub id='Is8RE'></sub></form><legend id='Is8RE'></legend><bdo id='Is8RE'><pre id='Is8RE'><center id='Is8RE'></center></pre></bdo></b><th id='Is8RE'></th></span></q></dt></tr></i><div id='Is8RE'><tfoot id='Is8RE'></tfoot><dl id='Is8RE'><fieldset id='Is8RE'></fieldset></dl></div>
          <bdo id='Is8RE'></bdo><ul id='Is8RE'></ul>
      1. <small id='Is8RE'></small><noframes id='Is8RE'>

        <legend id='Is8RE'><style id='Is8RE'><dir id='Is8RE'><q id='Is8RE'></q></dir></style></legend>

        azure 服务总线的 Azure Function App 延迟重试

        时间:2023-10-05

        1. <legend id='eE56k'><style id='eE56k'><dir id='eE56k'><q id='eE56k'></q></dir></style></legend>
          <tfoot id='eE56k'></tfoot>
            <tbody id='eE56k'></tbody>

                  <bdo id='eE56k'></bdo><ul id='eE56k'></ul>
                  <i id='eE56k'><tr id='eE56k'><dt id='eE56k'><q id='eE56k'><span id='eE56k'><b id='eE56k'><form id='eE56k'><ins id='eE56k'></ins><ul id='eE56k'></ul><sub id='eE56k'></sub></form><legend id='eE56k'></legend><bdo id='eE56k'><pre id='eE56k'><center id='eE56k'></center></pre></bdo></b><th id='eE56k'></th></span></q></dt></tr></i><div id='eE56k'><tfoot id='eE56k'></tfoot><dl id='eE56k'><fieldset id='eE56k'></fieldset></dl></div>
                • <small id='eE56k'></small><noframes id='eE56k'>

                  本文介绍了azure 服务总线的 Azure Function App 延迟重试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  首先让我解释一下我有什么.我自己有一个带有 Azure Function App 的 Azure 服务总线.服务总线设置为使用 SQL 过滤器将特定消息类型推送到特定主题.然后使用我的 Azure Function App 这些将获取最新消息然后处理它.

                  First let me explain what I have. I have myself an Azure Service Bus with an Azure Function App. The Service Bus is setup to use SQL Filters to push specific message types into specific topics. Then using my Azure Function App these will get the newest message and then process it.

                  一个基本的例子

                  1:我向我的 EmailAPI 发送请求

                  1: I send a request to my EmailAPI

                  2:EmailAPI 然后将一条新消息推送到具有电子邮件"类型的服务总线

                  2: EmailAPI then pushing a new message into the Service Bus with a type of "Email"

                  3:SQL 过滤器然后看到类型是电子邮件",并被放置在 Service Bux 中的电子邮件主题中

                  3: The SQL Filter then sees the type is of "Email" and is placed into the email Topic in the Service Bux

                  4:EmailListener Azure Function 监控服务总线并通知新消息

                  4: The EmailListener Azure Function monitors the Service bus and notices a new message

                  5:收集服务总线消息并处理它(基本上只是使用提供的信息发送电子邮件)

                  5: Gather the Service Bus message and process it (basically just send the email using the information provided)

                  现在假设由于某种原因 SMTP 服务器连接有点中断,有时我们在尝试发送电子邮件 (EmailListener) 时收到 TimeOutException.现在当抛出异常时会发生什么,Function App EmailListener 将立即尝试再次发送它,无需等待,它只会尝试再次发送它.它将总共执行 10 次,然后通知 Service Bus 将消息放入死信队列.

                  Now let's say for some reason the SMTP server connection is a little broken and some times we get a TimeOutException when attempting to send the email (EmailListener). What happens now when an exception is thrown, the Function App EmailListener will attempt to send it again instantly, no wait, it will just attempt to send it again. It will do this for a total of 10 times and then inform the Service Bus to place the message in the Dead Letter queue.

                  我正在尝试做的是,当抛出异常(例如 TimeOutException)时,我们会等待 X 时间,然后再尝试再次处理相同的消息.我查看了许多不同的帖子,讨论了 host.json 并尝试设置这些设置,但这些都没有奏效.我找到了一个解决方案,但是该解决方案要求您创建消息的克隆并将其推回服务总线并延迟处理时间.如果 Azure Service Bus/Function App 可以自行处理重试,我不希望实现自己的手动延迟系统.

                  What I am attempting to do is when an exception is thrown (such as TimeOutException), we wait X amount of time before attempting to process the same message again. I have looked around at many different posts talking about the host.json and attempting to set those settings, but these have not worked. I have found a solution, however the solution requires your to create a clone of the message and push it back into the Service Bus and give it a delayed process time. I would prefer not to implement my own manual delay system, if Azure Service Bus / Function App can deal with retries itself.

                  我遇到的最大问题(这可能取决于我的理解)是谁有错?是服务总线设置来处理重试策略,还是 Azure Function App 来处理在 X 时间后尝试重试.

                  The biggest issue I am having (which is probably down to my understanding) is who is at fault? Is it the Service Bus settings to handle the Retry Policy or is it the Azure Function App to deal with attempting to retry after X time.

                  我提供了一些代码,但我觉得代码并不能真正帮助解释我的问题.

                  I have provided a some code, but I feel code isn't really going to help explain my question.

                  // Pseudo code
                  public static class EmailListenerTrigger
                  {
                      [FunctionName("EmailListenerTrigger")]
                      public static void Run([ServiceBusTrigger("messages", "email", Connection = "ConnectionString")]string mySbMsg, TraceWriter log)
                      {
                             var emailLauncher = new EmailLauncher("SmtpAddress", "SmtpPort", "FromAddress");
                             try
                             {
                                 emailLauncher.SendServiceBusMessage(mySbMsg);
                             }
                             catch(Exception ex)
                             {
                                 log.Info($"Audit Log: {mySbMsg}, Excpetion: {ex.message}");
                             }
                      }
                  }
                  

                  参考一:https://blog.kloud.com.au/2017/05/22/message-retry-patterns-in-azure-functions/(Thread.Sleep 似乎不是一个好主意)

                  reference one: https://blog.kloud.com.au/2017/05/22/message-retry-patterns-in-azure-functions/ (Thread.Sleep doesn't seem like a good idea)

                  参考二:https://github.com/Azure/azure-functions-host/issues/2192(手动实现重试)

                  reference two: https://github.com/Azure/azure-functions-host/issues/2192 (Manually implemented retry)

                  参考三:https://www.feval.ca/posts/function-queue-retry/(这似乎是指我使用主题时的队列)

                  reference three: https://www.feval.ca/posts/function-queue-retry/ (This seems to refer to queues when I am using topics)

                  参考四:能否Azure服务在重试消息之前总线被延迟?(谈论延迟消息,但您需要手动将其从队列/主题中取出.)

                  reference four: Can the Azure Service Bus be delayed before retrying a message? (Talks about Defering the message, but then you need to manually get it back out the queue/topic.)

                  推荐答案

                  您或许可以使用 Durable Functions 解决您的问题.例如,有一个内置方法 CallActivityWithRetryAsync() 可以在活动函数抛出异常时重试.

                  You might be able to solve your issue with the use of Durable Functions. There is for example a built-in method CallActivityWithRetryAsync() that can retry when the activity functions throws an exception.

                  https://docs.microsoft.com/en-us/sandbox/functions-recipes/durable-diagnostics#calling-activity-functions-with-retry

                  您的流程可能是这样的:

                  Your flow would probably something like this:

                  1. 服务总线触发函数.这个启动了一个 Orchestrator 函数

                  1. Service Bus triggered Function. This one starts an Orchestrator Function

                  编排器调用您的活动函数(使用上述方法)

                  The orchestrator calls your activity function (using the aforementioned method)

                  这篇关于azure 服务总线的 Azure Function App 延迟重试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:Azure Functions:计时器触发器和消费计划问题 下一篇:Azure 函数 blob 绑定

                  相关文章

                • <i id='UPo0H'><tr id='UPo0H'><dt id='UPo0H'><q id='UPo0H'><span id='UPo0H'><b id='UPo0H'><form id='UPo0H'><ins id='UPo0H'></ins><ul id='UPo0H'></ul><sub id='UPo0H'></sub></form><legend id='UPo0H'></legend><bdo id='UPo0H'><pre id='UPo0H'><center id='UPo0H'></center></pre></bdo></b><th id='UPo0H'></th></span></q></dt></tr></i><div id='UPo0H'><tfoot id='UPo0H'></tfoot><dl id='UPo0H'><fieldset id='UPo0H'></fieldset></dl></div>
                • <tfoot id='UPo0H'></tfoot>
                    <legend id='UPo0H'><style id='UPo0H'><dir id='UPo0H'><q id='UPo0H'></q></dir></style></legend>
                    • <bdo id='UPo0H'></bdo><ul id='UPo0H'></ul>
                  1. <small id='UPo0H'></small><noframes id='UPo0H'>