Created
January 23, 2019 15:35
-
-
Save MattStypa/c5846e303a8be0dc25bbe18125080085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace App\Console\Commands; | |
use Illuminate\Container\Container; | |
use Illuminate\Console\Command; | |
use Illuminate\Queue\Jobs\SyncJob; | |
class QueueSyncRetry extends Command | |
{ | |
protected $signature = 'queue:sync-retry {id : The ID of the failed job}'; | |
protected $description = 'Retry failed job in sync mode'; | |
/** | |
* @var Container | |
*/ | |
protected $container; | |
/** | |
* DebugFailedJob constructor. | |
* | |
* @param Container $container | |
*/ | |
public function __construct(Container $container) | |
{ | |
parent::__construct(); | |
$this->container = $container; | |
} | |
/** | |
* Runs the command | |
*/ | |
public function handle() | |
{ | |
$id = $this->argument('id'); | |
$failedJob = $this->laravel['queue.failer']->find($id); | |
if (is_null($failedJob)) { | |
$this->error("Unable to find failed job with ID [{$id}]."); | |
return; | |
} | |
$job = new SyncJob($this->container, $failedJob->payload, 'artisan', 'sync'); | |
$job->fire(); | |
$this->laravel['queue.failer']->forget($id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment