Job has been attempted too many times or run too long Job has been attempted too many times or run too long laravel laravel

Job has been attempted too many times or run too long


Try to catch the exception in the failed method given by laravel

/*** The job failed to process.** @param  Exception  $exception* @return void*/public function failed(Exception $exception){    // Send user notification of failure, etc...}

and check whether your default queue driver in local is sync then its expected behavior.


I had the same problem

I fixed it by increasing the 'retry_after' parameter

make sure the retry_after value is greater than the time it takes a job to run

in config/queue.php file

    'connections' => [    'sync' => [        'driver' => 'sync',    ],    'database' => [        'driver' => 'database',        'table' => 'jobs',        'queue' => 'default',        'retry_after' => 9000,    ],


According to documentation, you can handle job failing in two common ways:

  • using failed job events
  • using failed() method.

In the first case, you can handle all jobs using Queue::failing() method. You'll receive Illuminate\Queue\Events\JobFailed event as a parameter, and it contains exception.

In another case, you can use failed() method, it should be placed near your handle() method. You can receive Exception $exception as a parameter too.

Example:

public function failed(\Throwable $exception){    // Log failure}

Hope this helps.