3

I am building a large application using Laravel and find the use of queue in this application. I am now using beanstalkd service for this. However, I am stuck in finding an answer for this set up. Is there a way to put the queue retries be processed in not instantly manner. I wanted it to be retried after n seconds. Thanks

Alister Bulman
  • 34,482
  • 9
  • 71
  • 110
jellyfication
  • 170
  • 2
  • 12

3 Answers3

2

Try using the inbuilt Queue service and use the following

Queue::later(Carbon::now()->addMinutes(1), $task);

Relevant docs

Scopey
  • 6,269
  • 1
  • 22
  • 34
  • Is this possible to implement this for retries? @scopey – jellyfication May 06 '15 at 02:36
  • It might be possible to hook into the `failing` hook and do a custom retry. Additionally, setting the `--delay` flag on your queue worker gives an ambiguous delay. Not entirely sure that there's a set way to delay specific retries otherwise. – Scopey May 06 '15 at 02:49
  • 3
    I just try sending out emails (and expecting them to fail) using the two following commands on Laravel 4.2: `php artisan queue:work --daemon --tries=3 --sleep=60` versus `php artisan queue:work --daemon --tries=3 --sleep=5 --delay=10` and I can confirm that using the second command, the retries were attempted after a 10 seconds delay instead of being retried immediately (which was the case when I used the first command). – Pierre Jun 10 '15 at 12:32
1

To delay the next retry just add --delay=[NUM_OF_SECONDS] to your command.

For example, to wait 30 seconds to retry after failing just run: php artisan queue:work tries=3 --delay=30

Jeremy
  • 3,620
  • 9
  • 43
  • 75
1

In the queue:work command --delay option is deprecated.

You have to use --backoff

--backoff[=BACKOFF]    The number of seconds to wait before retrying a job that encountered an uncaught exception [default: "0"]
b3ni
  • 149
  • 1
  • 8