In Laravel, you can configure a delay between retries for jobs using the retryAfter
method provided by the Illuminate\Bus\Queueable
trait. Here's how you can do it:
Open your job class file (Usually located in the app/Jobs
directory).
Add the Queueable
trait to your job class:
use Illuminate\Bus\Queueable;
retryAfter
method in your job class's retry
method to specify the delay in seconds. For example, if you want to retry the job after a delay of 10 seconds, you can set retryAfter(10)
:public function retry($delay = null)
{
$this->retryAfter(10);
}
tries
property declared in your job class. It represents the maximum number of times a job will be attempted before being marked as failed:public $tries = 3; // Example: Retry the job 3 times before marking it as failed
That's it! With these changes, your job will be retried after the specified delay between retries.