Queue task completion response

56 Views Asked by At

I have a queue. I use it for some task. After I invoke the queue in a controller, I want to wait for that task to finish. When that task is finished then only I return the response from the controller,

Will doing this defeat the concept of using queue.

I want to use the queue invocable somewhat like this

public async Task<IActionResult> controller(int x)
{
       int x = 0;
       x = _queue.QueueInvocableWithPayload<QueueInvokeClass,PayloadModel>(
              new PayloadModel(x));
       while(x != 1){}
       return Ok();
}


public int Invoke()
{
      //---Task---
      return 1;
}

I wanted to try something like this, only issue is I won't get the return 1 value from Invoke method.

Perhaps I can try making a flag in the database, and use that to check if the task has been finished.

My question is , should I be using a queue in such way, if yes then can it be achieved using the concept in the code above.

0

There are 0 best solutions below