1

I'm running Laravel 4.1.25 with iron-io/iron_mq 1.5.1 and this is my first try at queues. According to the documentation (http://laravel.com/docs/queues), when you're done processing a job, you should delete it from the queue.

However, during my testing, I've noticed that Laravel will return any job to the Iron.io queue if it throws an exception (documented behaviour), but if a job succeeds with no exceptions thrown, it vanishes from the queue.

Is that something specific to Iron.io (using a pull queue), and will it hurt if I run $job->delete() at the end, despite the fact that Laravel is clearing processed jobs already?

Wogan
  • 1,335
  • 12
  • 17

1 Answers1

3

So after digging around in the source code a bit, I found that if you add public $delete = true; to the class that contains your fire() method, Laravel will automatically delete completed jobs. This is referenced from Illuminate\Queue\Worker process(), where it checks for $job->autoDelete(), after calling $job->fire().

In my case this wasn't set, and I was unable to reliably reproduce the issue I was trying to fix. I'm settling for just setting $delete, since Laravel will return an Exception-throwing job to the queue regardless.

Wogan
  • 1,335
  • 12
  • 17
  • Are you saying it's not deleting by default unless you add that line? That seems odd. – Travis Reeder May 13 '14 at 15:48
  • @TravisR The documentation instructs you to delete the job manually, despite autoDelete() being a thing (and I looked at most of the code involved in the queue worker). I guess that they felt it was a sensible default, but it would have been nice to have the autoDelete() feature documented :) – Wogan May 13 '14 at 16:08