Azure webjob似乎不尊重MaxDequeueCount属性

Azure webjob似乎不尊重MaxDequeueCount属性,第1张

概述我有一个带有几个队列触发函数的Azure webjob. https://docs.microsoft.com/en-us/azure/app-service-web/websites-dotnet-webjobs-sdk-storage-queues-how-to#config上的SDK文档将MaxDequeueCount属性定义为: The maximum number of retries 我有一个带有几个队列触发函数的Azure webjob. https://docs.microsoft.com/en-us/azure/app-service-web/websites-dotnet-webjobs-sdk-storage-queues-how-to#config上的SDK文档将MaxDequeueCount属性定义为:

The maximum number of retrIEs before a queue message is sent to a
poison queue (default is 5).

但我没有看到这种行为.在我的webjob中我得到了:

JobHostConfiguration config = new JobHostConfiguration();config.Queues.MaxDequeueCount = 1;JobHost host = new JobHost(config);host.RunAndBlock();

然后我有一个队列触发的函数,我抛出一个异常:

public voID ProcessQueueMessage([QueueTrigger("azurewejobtestingqueue")] string item,TextWriter logger){   if ( item == "exception" )   {      throw new Exception();   }}

查看webjobs仪表板,我看到SDK进行了5次尝试(5是默认值,如上所述):

在第5次尝试之后,消息被移动到毒药队列.我希望看到1次重试(或没有重试?)而不是5次.

更新:启用Web应用程序的详细日志记录,并选择将这些日志保存到Azure Blob容器.找到一些与我的问题相关的日志,位于azure-jobs-host-archive容器中.这是一个示例,显示出队计数为96的项目:

{  "Type": "FunctionCompleted","EndTime": "2017-02-22T00:07:40.8133081+00:00","Failure": {    "ExceptionType": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException","ExceptionDetails": "Microsoft.Azure.WebJobs.Host.FunctionInvocationException: Exception while executing function: itemprocessor.ProcessQueueMessage ---> MyApp.Exceptions.MySpecialAppExceptionType: Exception of type 'MyApp.Exceptions.MySpecialAppExceptionType' was thrown.  },"ParameterLogs": {},"FunctionInstanceID": "1ffac7b0-1290-4343-8ee1-2af0d39ae2c9","Function": {    "ID": "MyApp.Processors.itemprocessor.ProcessQueueMessage","Fullname": "MyApp.Processors.itemprocessor.ProcessQueueMessage","Shortname": "itemprocessor.ProcessQueueMessage","Parameters": [      {        "Type": "QueueTrigger","Accountname": "MyStorageAccount","Queuename": "stuff-processor","name": "sourceFeedItemQueueItem"      },{        "Type": "BindingData","name": "dequeueCount"      },{        "Type": "ParameterDescriptor","name": "logger"      }    ]  },"Arguments": {    "sourceFeedItemQueueItem": "{\"SourceFeedUpdateID\":437530,\"podcastFeedID\":\"2d48D2sf2\"}","dequeueCount": "96","logger": null  },"Reason": "automaticTrigger","ReasonDetails": "New queue message detected on 'stuff-processor'.","StartTime": "2017-02-22T00:07:40.6017341+00:00","OutputBlob": {    "Containername": "azure-webjobs-hosts","Blobname": "output-logs/1ffd3c7b012c043438ed12af0d39ae2c9.txt"  },"ParameterLogBlob": {    "Containername": "azure-webjobs-hosts","Blobname": "output-logs/1cf2c1b012sa0d3438ee12daf0d39ae2c9.params.txt"  },"LogLevel": "Info","HostInstanceID": "d1825bdb-d92a-4657-81a4-36253e01ea5e","Hostdisplayname": "itemprocessor","SharedQueuename": "azure-webjobs-host-490daea03c70316f8aa2509438afe8ef","InstanceQueuename": "azure-webjobs-host-d18252sdbd92a4657d1a436253e01ea5e","Heartbeat": {    "SharedContainername": "azure-webjobs-hosts","SharedDirectoryname": "heartbeats/490baea03cfdfd0416f8aa25aqr438afe8ef","InstanceBlobname": "zd1825bdbdsdgga465781a436q53e01ea5e","ExpirationInSeconds": 45  },"WebJobRunIDentifIEr": {    "WebSitename": "myappengine","JobType": "Continuous","Jobname": "itemprocessor","RunID": ""  }}

我正在进一步寻找的是日志,它会显示特定队列项的详细信息,其中处理成功(因此从队列中删除)或由于异常而失败并放置在毒性队列中.到目前为止,我还没有找到任何显示详细信息的日志.上面输出中引用的日志文件不包含此类数据.

更新2:看看我的毒药队列的状态,看起来它可能是一支冒烟的q,但我太密集了,不能把2和2放在一起.查看下面队列的屏幕截图,您可以在那里多次看到带有ID(左栏)431210的消息.多次出现这一事实告诉我原始队列中的消息未正确失败.

解决方法 正如Rob W所提到的,当使用windowsAzure.Storage>时会出现此问题. 7.1.2.该问题显然已于 issue #1141修复,但尚未发布.

贡献者asifferman在issue #985上共享了一个code snippet in a comment post.这似乎解决了这个问题(它对我来说非常合适).

如果链接腐烂,并满足SO规则,这里的帖子和代码片段:

For those (like me) who cannot wait the next release to get the
WebJobs SDK to work with the latest releases of Azure Storage,and
based on the explanations of @brettsam,you can simply write a custom
CustomQueueProcessorFactory to create a new CloudQueueMessage in
copyMessagetoPoisonQueueAsync.

namespace ConsoleApplication1{    using Microsoft.Azure.WebJobs.Host.Queues;    using Microsoft.windowsAzure.Storage.Queue;    using System.Threading;    using System.Threading.Tasks;    public class CustomQueueProcessorFactory : IQueueProcessorFactory    {        public QueueProcessor Create(QueueProcessorFactoryContext context)        {            return new CustomQueueProcessor(context);        }        private class CustomQueueProcessor : QueueProcessor        {            public CustomQueueProcessor(QueueProcessorFactoryContext context)                : base(context)            {            }            protected overrIDe Task copyMessagetoPoisonQueueAsync(CloudQueueMessage message,CloudQueue poisonQueue,CancellationToken cancellationToken)            {                var newMessage = new CloudQueueMessage(message.ID,message.PopReceipt);                newMessage.SetMessageContent(message.AsBytes);                return base.copyMessagetoPoisonQueueAsync(newMessage,poisonQueue,cancellationToken);            }        }    }}

Then in your Main,you just have to set the custom queue processor
factory in the job host configuration:

var config = new JobHostConfiguration();config.Queues.QueueProcessorFactory = new CustomQueueProcessorFactory();

I Could get it work with windowsAzure.Storage 8.1.1 and Microsoft.Azure.WebJobs 2.0.0. Hope that helps!

总结

以上是内存溢出为你收集整理的Azure webjob似乎不尊重MaxDequeueCount属性全部内容,希望文章能够帮你解决Azure webjob似乎不尊重MaxDequeueCount属性所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1137219.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存