我有一个使用Azure队列消息的工作者角色在后台执行一些处理。 当我检查我的日志似乎在处理消息,但仍然在我的日志中我得到以下异常(粘贴一些相关的材料从长期错误日志只)也不例外记录:指定的消息不存在。 ErrorCode:MessageNotFound Prod-WorkerError上下文
System.Net.WebException Microsoft.WindowsAzure.Storage.StorageException Exception messages: The remote server returned an error: (404) Not Found. The remote server returned an error: (404) Not Found. Stack Traces: at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand
1 cmd, IRetryPolicy policy, OperationContext operationContext) --- Next Call Stack: at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand
1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Queue.CloudQueue.DeleteMessage(String messageId, String popReceipt, QueueRequestOptions options, OperationContext operationContext) at InnovativeExams.Azure.CloudStorage.AzureQueue`1.DeleteMessage(T message) The specified message does not exist. ErrorCode:MessageNotFound Prod-WorkerError Context
这里是我在工作角色中的代码:
private void ProcessQueueMessage(object queueMessageToProcess)
{
var queueMessage = queueMessageToProcess as EventCompletedQueueMessage;
try
{
if (_eventCompletedProcessor.Process(queueMessage))
_azureQueue.DeleteMessage(queueMessage);
}
catch (Exception ex)
{
_logger.LogError(string.Format("Event Completed message <{0}> was not processed due to an exception", queueMessage.Id), ex, LogSources.WorkerRole_EventCompletedDispatcher);
}
}
上面的异常被捕获到上面的catch块中并被记录下来。
我认为当工作角色尝试删除队列中的消息并且未找到消息时会出现问题。
需要某人的帮助来帮助我解决这个错误并知道背景有什么问题。
几个问题在评论问:
1)你运行你的Worker角色的多个实例?
答:这是一个现有的应用程序,我想通过使用ThreadPool来预先实例化,准备好工作的线程。
2)你如何“获得”你的工作角色的消息?您是否使用某种领导选举模式来决定哪个实例获取消息?
答:是的,有一个框架可以确定QueueMessage被处理的适当调度器。
3)当您收到消息时,这些消息的可见性超时是多少?
答:它设定为120,
4)多长时间需要为你处理这些消息即多少时间得到消息,并删除邮件之间?
答:我对此不太确定。
很少有问题(请更新您的问题并附上答案):1)您是否正在运行多个工作角色的实例? 2)你如何“获取”你的工作角色中的消息?您是否使用某种领导选举模式来决定哪个实例获取消息? 3)当你收到消息时,这些消息的可见性超时是多少? 4)处理这些消息需要多长时间,即获取消息和删除消息之间需要多长时间? –
@GauravMantri编辑了这个问题。请检查。 – Maninder