I have a few Laravel jobs that involve long wait periods (15-60 seconds) for third party APIs to finish tasks before I can continue. It feels pretty wasteful to keep the thread locked while it polls for the job to complete.
Is there a way to update the payload / state of the job and requeue it so that the job can resume and poll again once a few other jobs have completed?
I'm thinking something like:
// In a handling method within the job.
$this->state = 'waitingForSomeTask';
// Save the payload / state of this job (this is the "missing" method)
$this->save();
// Put the task back on the queue with a five second delay
$this->release(5);
From here, the next time the job handler runs, it could pickup where it left off (job variables having been carried over) - check to see if the task is complete and continue if so; if not, it would just requeue the job again.
I haven't seen this mentioned anywhere in the official documentation or elsewhere, so is there a better / more "Laravel-esque" way to do this?
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2iApVki
via IFTTT
Aucun commentaire:
Enregistrer un commentaire