Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Allow to retry jobs by queue name #36898

Merged
merged 2 commits into from Apr 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Illuminate/Queue/Console/RetryCommand.php
Expand Up @@ -18,6 +18,7 @@ class RetryCommand extends Command
*/
protected $signature = 'queue:retry
{id?* : The ID of the failed job or "all" to retry all jobs}
{--queue= : Name of the queue to be retried}
{--range=* : Range of job IDs (numeric) to be retried}';

/**
Expand Down Expand Up @@ -62,6 +63,16 @@ protected function getJobIds()
return Arr::pluck($this->laravel['queue.failer']->all(), 'id');
}

if ($queue = $this->option('queue')) {
$ids = collect($this->laravel['queue.failer']->all())->where('queue', $queue)->pluck('id')->toArray();

if (count($ids) === 0) {
$this->error("Unable to find failed jobs in a queue named [{$queue}].");
}

return $ids;
}

if ($ranges = (array) $this->option('range')) {
$ids = array_merge($ids, $this->getJobIdsByRanges($ranges));
}
Expand Down