mercredi 17 août 2016

How to avoid waiting for the Laravel queue and continue with functionality

This is probably a very trivial/novice question. I have started using Laravel Queue in one of my controller functions; however, when I dispatch the job, I have to wait for the queue to finish before it lets me continue with the function. I thought the whole concept behind queues is that it lets you process time-intensive tasks in the background so you can continue with rest of functionality.

This is what my controller looks like:

public function postCreate(Request $request)
{
    // Validate Request
    $this->validate($request, $this->rules());

    // I have to wait for this to finish before it lets me continue
    // I want this to be processed in the background instead
    $this->dispatchFrom('App\Jobs\GenerateReport', $request);

    return json_encode([
        'html' => '<p>some html</p>'
    ]);
}



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire