$job->release() is not putting back on queue
Asked Answered
D

1

5

Very new to queues so be gentle. To my understanding, $job->release() is supposed to put the job back on the queue. I currently have the code below but it only runs the job through the queue once. I need to be able to run it through up to 5 times and if it fails again, delete it or something.

Worker:

public function fire($job, $data)
{
    if ($job->attempts() < 5) {
        \Log::error($job->attempts());
        $job->release();
    }

}

PUSH!:

 Queue::push(
     'ClassName',
      [
         'path' => $path;
      ]

Trying to do this locally with sync. Tried running queue:listen and queue:work, then running the push code. Only logged 1 entry. Let me know if you need more info.

Darcee answered 20/1, 2015 at 17:24 Comment(0)
D
9

Turns out $job->release() doesn't work when using the sync driver.

Darcee answered 20/1, 2015 at 22:30 Comment(1)
The sync driver is essentially the same as running your code synchronously, so there is no queue to release the job back to.Grapeshot

© 2022 - 2024 — McMap. All rights reserved.