Search code examples
laravellaravel-4queuesynchronizationpush-queue

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


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.


Solution

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