I know that I can retry jobs that have failed in my Laravel application by using: php artisan queue:retry 5
OR php artisan queue:retry all
to push them back onto the queue.
What I would like to achieve though is to only retry failed jobs from a single queue. Such as php artisan queue:retry all --queue=emails
which does not work.
I could however go through each manually by ID php artisan queue:retry 5
but this does not help if I have 1000's of records.
So in summary, my question is, how can I retry all failed jobs on specific queue?
Maybe you can create another command
lets say
command : php artisan example:retry_queue emails
class RetryQueue extends Command
{
protected $signature = 'example:retry_queue {queue_name?}';
protected $description = 'Retry Queue';
public function __construct()
{
parent::__construct();
}
public function handle()
{
// if the optional argument is set, then find all with match the queue name
if ($this->argument('queue_name')) {
$queueList = FailedJobs::where('queue', $this->argument('queue_name'))->get();
foreach($queueList as $list) {
Artisan::call('queue:retry '.$list->id);
}
} else {
Artisan::call('queue:retry all');
}
}
}