クラウドキューのメッセージを更新しようとすると、例外が発生します。
例外は次のとおりです。
System.ArgumentNullException was unhandled
Message=Value cannot be null.
Parameter name: messageId
Source=Microsoft.WindowsAzure.StorageClient
ParamName=messageId
StackTrace:
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.get_Result()
at Microsoft.WindowsAzure.StorageClient.Tasks.Task`1.ExecuteAndWait()
at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImplWithRetry(Func`1 impl, RetryPolicy policy)
at Microsoft.WindowsAzure.StorageClient.CloudQueue.UpdateMessage(CloudQueueMessage message, TimeSpan visibilityTimeout, MessageUpdateFields updateFields)
at WorkerRole.WorkerRole.DoTask(Task task) in C:\Users\ALICE\Desktop\Diplloma\AG - Copy\AzureGrid\WorkerRole\WorkerRole.cs:line 133
at WorkerRole.WorkerRole.Run() in C:\Users\ALICE\Desktop\Diplloma\AG - Copy\AzureGrid\WorkerRole\WorkerRole.cs:line 51
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRoleInternal()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.StartRole()
at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<StartRole>b__1()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
私のコードは次のとおりです。
private void DoTask(Task task)
{
CloudQueueMessage resultsMessage;
// Queue a status message to indicate this worker is starting the task.
task.TaskStatus = Task.Status.Running;
task.Worker = System.Net.Dns.GetHostName();
resultsMessage = task.Message;
ResultsQueue.UpdateMessage(resultsMessage, TimeSpan.FromSeconds(QueueTimeout), MessageUpdateFields.Content | MessageUpdateFields.Visibility);
Trace.WriteLine("Executing task " + task.TaskId.ToString() + " for job " + task.JobId + ", project " + task.ProjectName,"Information");
using (GridWorker gridWorker = new AppWorker())
{
gridWorker.Execute(task);
}
// Queue results.
task.TaskStatus = Task.Status.Complete;
resultsMessage = task.Message;
ResultsQueue.UpdateMessage(resultsMessage, TimeSpan.FromSeconds(QueueTimeout), MessageUpdateFields.Content | MessageUpdateFields.Visibility);
}
タスクオブジェクトの作成方法は次のとおりです
public override void Run()
{
CloudQueueMessage taskMessage;
Task task;
// This is a sample worker implementation. Replace with your logic.
Trace.WriteLine("Initializing", "Information");
LoadConfigurationSettings();
OpenQueues();
Trace.WriteLine("Initializing", "Ready for work");
// Work loop. Read a task from the queue. If there is a task, execute it and pass work output to the results queue. Loop.
while (true)
{
taskMessage = TaskQueue.GetMessage(TimeSpan.FromSeconds(QueueTimeout));
//taskMessage = TaskQueue.PeekMessage();
if (taskMessage != null)
{
task = new Task(taskMessage);
DoTask(task);
TaskQueue.DeleteMessage(taskMessage);
}
else
Thread.Sleep(SleepInterval * 1000);
}
}
これは私の最初のアプリケーションであり、何をすべきかわかりません。