in my application I send some call on 10 process and I wait the response and if one of the call down or can not access the user whatever I want recall the user 3 times and I use it :
<?php
namespace App\Jobs;
use App\Library\Calling;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
class ProcessPodcast implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
public function handle () {
$result = (new Calling)->Phone('xxx')->Call();
/**
* result is an array
* - result['status'] => 1,2,3,4
* 1 -> accepted
* 2 -> rejected
* 3 -> can not access the user
* 4 -> error occurred
*/
if ( in_array($result['status'], [1, 2]) ) {
// in there job will be released
} elseif ( in_array($result['status'], [3, 4]) ) {
// in there it must recall after 3 seconds the user
// and if the attempts count is 3 release the job
// but how ?
}
}
}