[英]How to get status of the message which is added in QueueTrigger?
I have a continuous running webjob that gets triggered to do background tasks. 我有一个连续运行的webjob,被触发执行后台任务。 When the job is triggered to do the work I cannot find a way to trace or check whether the job has completed successfully or not.
当作业被触发执行工作时,我找不到追踪或检查作业是否成功完成的方法。
Is there a way that I could easily check the status of the triggered job for a specific message? 有没有一种方法可以方便地检查特定消息的触发作业状态?
var taskId =_service.GetTaskId();
CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
CloudQueue _cloudQueue = queueClient.GetQueueReference("taskqueue");
_cloudQueue.CreateIfNotExists();
var taskInfo = new TaskInformation
{
TaskId = taskId,
};
var queueMessage = new CloudQueueMessage(JsonConvert.SerializeObject(taskInfo));
await _cloudQueue.AddMessageAsync(queueMessage);
// is it possible to get the status of the queueMessage here?
// Whether the queueMessage is completed running successfully or it has failed?
Function: 功能:
public async Task Process(
[QueueTrigger("taskqueue")] TaskInformation taskInfo, string id,
int dequeueCount)
{
//this process might take a while to complete...
await _application.Run(taskInfo.TaskId);
}
Is there a way that I could easily check the status of the triggered job for a specific message?
有没有一种方法可以方便地检查特定消息的触发作业状态?
Based on my experience, I don't think that there is an easy way to check the status of the triggered job a sepcific meesage. 根据我的经验,我认为没有一种简单的方法可以通过特定的消息来检查已触发作业的状态。
If you want to know the status of the triggered job for a specific message,I recommand you could use a table to store the task id, queue id, queue message content in another table. 如果您想了解特定消息的已触发作业的状态,我建议您可以使用一个表将任务ID,队列ID,队列消息内容存储在另一个表中。 On my opinon, as an execution task, the log of execution task is very important.
在我看来,作为执行任务,执行任务的日志非常重要。
1.After add the queue message into the queue you cloud log the queue info into the table. 1.将队列消息添加到队列后,您将队列信息云记录到表中。
await _cloudQueue.AddMessageAsync(queueMessage);
//log the queue message info into a table.
2.During trigger the webjob before task run and after task run then log the corrosponding info. 2.在任务运行之前和任务运行之后触发网络作业期间,然后记录相应信息。
//log start to execute the queue message
await _application.Run(taskInfo.TaskId);
//log finished executing the queue message. succefully or failed.
3.On the table to query an action on time interval to find whether the task finished from the table. 3.在表上查询时间间隔上的操作,以从表中查找任务是否完成。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.