如我的Stack Overflow问题Azure webjob not appearing to respect MaxDequeueCount property所示,我中毒了(实际上有些物品可能永远不会中毒,只是出队,失败并重试并无休止地失败) .
Webjobs SDK自动处理队列触发消息的重试和中毒,我正在寻找包含该处理细节的日志 .
例如,我可以看到我的函数通过在 https://myappengine.scm.azurewebsites.net/vfs/data/jobs/continuous/StuffProcessor/job_log.txt
查看webjob通过SCM的日志来检测到新的队列项目(顺便说一下,如果我在Web应用程序上启用了对Azure存储的详细日志记录,我可以获得相同的信息吗?一个Blob?) .
[02/22/2017 01:47:22 > ec8d0f: INFO] Executing: 'StuffProcessor.ProcessQueueMessage' - Reason: 'New queue message detected on 'stuff-processor'.'
[02/22/2017 01:47:26 > ec8d0f: INFO] Executed: 'StuffProcessor.ProcessQueueMessage' (Succeeded)
[02/22/2017 01:47:26 > ec8d0f: INFO] Executing: 'StuffProcessor.ProcessQueueMessage' - Reason: 'New queue message detected on 'stuff-processor'.'
一旦我在Web应用程序上启用了对Azure存储的详细日志记录,我还可以通过查看 azure-jobs-host-archive
容器中的日志来获取有关项目出列计数的一些信息:
{
"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": ""
}
}
我找不到的是日志,它显示特定队列项的详细信息,其中处理由于异常而失败并被放置在毒性队列中 . 我正在寻找这些以试图进一步解决明显忽略MaxDequeueCount属性 . 这是记录的吗?
更新:我找到了帖子Azure WebJobs with Storage Queue and Exceptions,它包含以下截图:
该屏幕截图显示了标准"New queue message detected..."消息(我在Azure上看到并在模拟器中本地运行),它还显示"Message has reached MaxDequeueCount of X...Moving message to queue 'xyz-poison'",我只在模拟器中本地看到 . 基于Azure的运行时是否由于某种原因未显示此信息?在控制台窗口中本地运行或通过webjobs仪表板或在Azure上运行时,我从未看到与此类有关的中毒相关消息 .
2 回答
您使用的是Azure Storage版本8. *?它包含一个重大变化 .
当队列消息对象插入Azure Storage 8中的消息队列时,原始队列消息对象的消息ID将被新插入消息的唯一消息ID覆盖 .
这意味着它将丢失对毒药消息的引用,并且无法再将其删除 .
https://github.com/Azure/azure-webjobs-sdk/issues/985
至于日志记录,有两个选项:
创建自己的QueueProcessorFactory和QueueProcessor - 您可以覆盖处理有害消息的方法以产生更多的调试输出 . 如果您希望继续使用Azure Storage 8. *,那么您也可以完全解决该问题 .
注册跟踪监视器 . https://github.com/Azure/azure-webjobs-sdk-extensions/wiki/Error-Monitoring#tracemonitor
在上一篇文章中,您具有触发功能,如下所示
您写入 Logger 的任何内容都应显示在WebJobs仪表板上的日志中 . 我的建议是:
将'if(item ==“exception”)'更改为'if(item.ToLower() . StartsWith(“exception”)' . 然后在测试时向异常消息附加一个数字 . 将队列消息的文本记录到TextWriter因此您可以确定您正在查看您认为正在检查的相同消息 .
您可以将消息的出队计数作为函数的参数 . 见here . 查看示例中的FailAlways方法 . 也将此记录到TextWriter .
尝试在本地运行 . 所有输出都将写入控制台窗口 . 看看你是否有同样的行为 .
我真的很想找到造成这种行为的原因,所以如果你破解它,请务必告诉我们!