I have a queued job in Laravel that fails from time to time because of an external API failing due to high load. The problem is that my choices appear to be to have the Laravel Queue continue to hammer the API with requests until it succeeds or tell it to stop after X number of requests.
Is there any way for me to, based on how the job fails, tell it to try again in 5 minutes instead of continuing to hammer away?
I want to use the built in queue handler, but the retry functionality doesn't appear to be built to handle real life scenarios of failure. I would think that many reasons for failing a job wouldn't be solved by immediately trying again.
You can even retry all jobs at once by executing the php artisan queue:retry --all command. Alternatively, if you want to retry failed jobs from a certain queue, you can execute the php artisan queue:retry --queue=high-priority command.
Sync, or synchronous, is the default queue driver which runs a queued job within your existing process. With this driver enabled, you effectively have no queue as the queued job runs immediately.
Jobs and QueuesThe line itself is the Queue, and each customer in the line is a Job. In order to process Jobs in the Queue you need command line processes or daemons. Think of launching a queue daemon on the command line as adding a new bank teller to the pool of available bank tellers.
Laravel 8
/**
* The number of seconds to wait before retrying the job.
*
* @var int
*/
public $backoff = 3;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With