Laravel Queue Delays Not Working

This had me stupmed for several hours, Google searches only helped so much, however I should have paid more attention to the Laravel docs instead!

Before we start, I fell foul of the following in my .env file, where it says QUEUE_DRIVER=redis or sync etc, in Laravel 5.7 and onwards this has been changed to QUEUE_CONNECTION=redis instead.

I'm not sure why my .env had this wrong, but it's worth checking to see if yours is the same too. Dispatching events to the queue actually started working after i made this change, however the delays did not. Read on to find out why.

Queueing Notifications

As per the Laravel 5.7 docs: https://laravel.com/docs/5.7/notifications#queueing-notifications

if you want to push your notifications onto a queue, you need to add the ShouldQueue interface and Queuable trait on your notification class. Check out the example from the above link.

class InvoicePaid extends Notification implements ShouldQueue
{
use Queueable;
}

I was missing the "implements ShouldQueue" Interface. Once i added this, delays were working as expected!


More Posts

How do Enums work in PHP?

Ever been unsure about Enums or why you'd use them? In this post i'll show you real world examples and...