Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

t0berius's avatar

laravel queue (retry jobs 5 times, after 5 minutes if it failed) & mark job as failed

Dear community,

I've got a queue running some callback requests to endpoint of my users.

Here's the code of my queue.

    public function handle()
{
    //send webrequest here....
    
//check the response of user backend
    if ($res->getStatusCode() != 200 || $res->getBody()->getContents() != "*received*")
        throw new Exception('callback url not reachable');
}

public function failed(Exception $exception)
{
    //check tries and try again if needed

//check if job failed for 5 times
//if not ->retry again in 5 minutes, increment the times tried
//if yes ->disable API access, send email

    Log::info("user email send,  callback disabled!");
}

How to let the job fail (my current exception makes the whole job end), when webrequest answer is != "received" and check if the certain job failed 5 times? If a job failed it should be tried again in 5 minutes.

I don't understand the doc regarding these points.

0 likes
3 replies
t0berius's avatar

bump nobody already got the same problem? I think it's not that exotic to check the callbacks of API requests and disable them when failing many times.

FedericoPD's avatar

Hey jaheller,

I have exactly the same problem, did you manage to find a solution? So far what im doing is firing a new instance of the job with a delay, however it keeps the initial one in the queue and that's no good.

Please or to participate in this conversation.