gpt4 book ai didi

Azure 函数(服务总线触发器)System.OperationCanceledException

转载 作者:行者123 更新时间:2023-12-03 03:36:35 32 4
gpt4 key购买 nike

我有一个 Azure Function (.net 6.0),它从服务总线接收消息。 99% 的消息处理得很好,但时不时地我会在 Application Insights 中收到 System.OperationCanceledException。

调用堆栈:

System.OperationCanceledException:
at Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync (Microsoft.Azure.WebJobs.Extensions.ServiceBus, Version=5.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at Microsoft.Azure.WebJobs.ServiceBus.Listeners.ServiceBusListener+<ProcessMessageAsync>d__26.MoveNext (Microsoft.Azure.WebJobs.Extensions.ServiceBus, Version=5.5.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.ServiceBus.ServiceBusProcessor+<OnProcessMessageAsync>d__104.MoveNext (Azure.Messaging.ServiceBus, Version=7.8.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.ServiceBus.ReceiverManager+<OnMessageHandler>d__19.MoveNext (Azure.Messaging.ServiceBus, Version=7.8.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
at Azure.Messaging.ServiceBus.ReceiverManager+<ProcessOneMessage>d__15.MoveNext (Azure.Messaging.ServiceBus, Version=7.8.1.0, Culture=neutral, PublicKeyToken=92742159e12e44c8)

调用堆栈(只是我的代码):

System.OperationCanceledException
Microsoft.Azure.WebJobs.ServiceBus.MessageProcessor.CompleteProcessingMessageAsync
[external code]
Azure.Messaging.ServiceBus.ServiceBusProcessor+<OnProcessMessageAsync>d__104.MoveNext
[external code]
Azure.Messaging.ServiceBus.ReceiverManager+<OnMessageHandler>d__19.MoveNext
[external code]
Azure.Messaging.ServiceBus.ReceiverManager+<ProcessOneMessage>d__15.MoveNext

Application Insights

查看 FormattedMessage:它似乎在 ProcessMessageCallback 上失败。我查了一下,我能找到的唯一信息是这样的:Errors returned from the user's processMessagecallback pass to subscribe。

失败的方法是:Azure.Messaging.ServiceBus.ServiceBusProcessor+d__104.MoveNext

对我来说,这似乎是 ServiceBus 问题,而不是我的代码。我正在使用 Microsoft.Azure.WebJobs.Extensions.ServiceBus v5.5.1。

其他人是否遇到过此问题或知道如何解决此问题?

更新:我添加了异常处理,希望能够捕获更多信息:

    catch (OperationCanceledException ex)
{
throw new OperationCanceledException(ex.Message);
}
catch (Exception ex)
{
throw new ApplicationException(ex.Message);
}

最佳答案

当函数主机尝试停止或回收实例时(例如在缩减期间),可能会发生这种情况。如果该函数在 3 个实例上运行,并缩小到在 2 个实例上运行,则被“杀死”的实例将被取消。

关于Azure 函数(服务总线触发器)System.OperationCanceledException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73136474/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com