正如我的Stack Overflow问题Azure webjob not appearing to respect MaxDequeueCount property所示,我在解决了一个问题,即尽管我将MaxDequeueCount属性设置为1,但有些项目在被中毒之前已经多次出列(在事实上,有些物品可能永远不会中毒,只是出列,失败,重试并无休止地失败。)
Webjobs SDK自动处理队列触发消息的重试和中毒,并且我正在查找包含该处理细节的日志。
例如,我可以看到我的函数通过https://myappengine.scm.azurewebsites.net/vfs/data/jobs/continuous/StuffProcessor/job_log.txt
处的SCM查看webjob的日志来检测到新的队列项目(顺便说一句,如果我已启用详细日志记录到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'.'
我还可以通过在网络应用上启用详细记录到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,其中包含以下屏幕截图:
该屏幕截图显示标准"检测到新队列消息..."消息(我在Azure上看到并在模拟器中本地运行)并且它还显示"消息已达到X的MaxDequeueCount ...将消息移动到队列' xyz-poison'" ,我仅在模拟器中本地查看。基于Azure的运行时是否由于某种原因未显示此信息? 在控制台窗口或通过webjobs仪表板在本地运行或在Azure上运行时,我从未看到与此类有关的中毒相关消息。
答案 0 :(得分:1)
您使用的是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
var traceMonitor = new TraceMonitor()
.Filter(p => true, "Trace Handler")
.Subscribe(TraceHandler.Process);
config.Tracing.Tracers.Add(traceMonitor);