3

How can I push a job back into the queue.

I tired

$job->release()

but it is pushing back on to the queue so the next job in the queue is that same job, I want the job send back to the last of the queue,which executes last. How can I do that?

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
AH.
  • 741
  • 1
  • 12
  • 27
  • Delete the job and push it back as a new job. – Bogdan Jul 24 '15 at 10:06
  • Is there any other solution like $job->release() ? – AH. Jul 24 '15 at 10:12
  • There is a priority parameter that can be used for release, but Laravel's job [`release`](https://github.com/laravel/framework/blob/5.1/src/Illuminate/Queue/Jobs/BeanstalkdJob.php#L84-L91) method doesn't offer any way for it to be passed. It just uses the default priority constant `Pheanstalk::DEFAULT_PRIORITY` it gets from [Pheanstalk](https://github.com/pda/pheanstalk) (the package it uses to handle Benastalk queues). So if you want to be able to handle more specific properties of the queues you should use Pheanstalk instead. – Bogdan Jul 24 '15 at 10:35

1 Answers1

0

You can throw an exception making the job fail.

And depending on how many tries the queue:work will fire, the job will ultimately end up in the failed_jobs table (if you have that defined.)

You can then push the job back on to the queue from the failed_jobs table.

Ralla
  • 168
  • 1
  • 9