Skip to content

Commit

Permalink
[8.x] New JobRetrying event dispatched (laravel#39097)
Browse files Browse the repository at this point in the history
* New JobRetrying event dispatched

* Style fixes

* formatitng

Co-authored-by: Taylor Otwell <taylorotwell@gmail.com>
  • Loading branch information
2 people authored and victorvilella committed Oct 12, 2021
1 parent 6126db2 commit ffa8f90
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Illuminate/Queue/Console/RetryCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use DateTimeInterface;
use Illuminate\Console\Command;
use Illuminate\Contracts\Encryption\Encrypter;
use Illuminate\Queue\Events\JobRetryRequested;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use RuntimeException;
Expand Down Expand Up @@ -41,6 +42,8 @@ public function handle()
if (is_null($job)) {
$this->error("Unable to find failed job with ID [{$id}].");
} else {
$this->laravel['events']->dispatch(new JobRetryRequested($job));

$this->retryJob($job);

$this->info("The failed job [{$id}] has been pushed back onto the queue!");
Expand Down
45 changes: 45 additions & 0 deletions src/Illuminate/Queue/Events/JobRetryRequested.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php

namespace Illuminate\Queue\Events;

class JobRetryRequested
{
/**
* The job instance.
*
* @var \stdClass
*/
public $job;

/**
* The decoded job payload.
*
* @var array|null
*/
protected $payload = null;

/**
* Create a new event instance.
*
* @param \stdClass $job
* @return void
*/
public function __construct($job)
{
$this->job = $job;
}

/**
* The job payload.
*
* @return array
*/
public function payload()
{
if (is_null($this->payload)) {
$this->payload = json_decode($this->job->payload, true);
}

return $this->payload;
}
}

0 comments on commit ffa8f90

Please sign in to comment.