Is there is no harm to put while loop (with sleep) in the Job class? It will need to wait for the response via API, it will try 5 attempts.
Let say $dispatched
is true
then it will need to make multiple dispatch but dispatch(New ProcessOne);
has to be done first before executing to next the dispatch like dispatch(New ProcessTwo);
How can that be done?
For example:
class WaitUntilDispatched implements ShouldQueue
{
public function handle()
{
$count = 1;
$dispatched = false;
while ($count <= 5 && !$dispatched) {
if (Api::dipatched($this->token)) {
$dispatched = true;
}
$count++;
sleep(20);
}
if ($dispatched) {
Log::info('Dispatched response from API');
dispatch(New ProcessOne);
dispatch(New ProcessTwo);
dispatch(New ProcessThree);
}
}
}
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2ivcIJi
via IFTTT
Aucun commentaire:
Enregistrer un commentaire