0

I have a continuous running webjob that gets triggered to do background tasks. 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);
    }
akd
  • 6,538
  • 16
  • 70
  • 112
  • If you're using queues, if the message fails to complete 'x' times (configurable) it gets moved to the poison queue. You can trigger an event based on this notifying you that it failed. – lopezbertoni Nov 03 '17 at 13:06
  • When a queue is added to trigger the function I would like to find out whether that message is been completed or not. The process should not wait 10 minutes to find out what happened. This is on the web site that it will be querying an action on time interval to find whether the task is completed or not. Any better idea? – akd Nov 03 '17 at 13:12

1 Answers1

0

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. 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.

 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.

 //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.

Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • This is exactly what I ended up implementing. But I was really hoping that there is a built-in solution (api) to get the status of the message by the id. The scheduled jobs do have some helpful apis to get the status but this doesn't seem to be the case for continuous running jobs. – akd Nov 06 '17 at 09:21
  • As far as I know there is no this api for getting queue status. – Tom Sun - MSFT Nov 06 '17 at 09:25