dimanche 26 juin 2016

Getting Queued Jobs response Laravel 5.2

currently I have the following set up, a route that is calling a function in my controller that is in turn queuing a job.

//My Route

Route::get('/testJob', 'Controller@testJob');

//My Controller

public function testJob()
{
    $job = (new testJob())->delay(5);
    $this->dispatch($job);
}

//My job

public function handle()
{   
    require 'testAPICall.php';
    // echo $response;
    return $response;
}

//testAPICall.php

$response = 'this is the response';

//Queue After

Queue::after(function (JobProcessed $event) {
    echo var_dump($event->data);
});

What I would like to be able to do, is access the response returned by the job in Queue::after, or alternatively, pass a callback into the queue to be execute after the job, again with access to the response from the job.

Is this something that is possible with Laravel Queues, and if so how would I go about this?

Cheers, Jack.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire