Skip to content

Instantly share code, notes, and snippets.

@MattStypa
Created January 23, 2019 15:35
Show Gist options
  • Save MattStypa/c5846e303a8be0dc25bbe18125080085 to your computer and use it in GitHub Desktop.
Save MattStypa/c5846e303a8be0dc25bbe18125080085 to your computer and use it in GitHub Desktop.
<?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