PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, January 25, 2022

[FIXED] Jobs Not Queuing (E-Mails Sending Immediately)

 January 25, 2022     laravel, laravel-5, php     No comments   

Issue

I'm currently running into an issue where my e-mails are not queuing in Laravel 5.8.

I have run:

php artisan queue:table 
php artisan migrate
php artisan config:clear
php artisan config:cache

Controller:

$when = now()->addMinutes(2);

$customer->notify((new CustomerOrderItemStatusNotification($orderItem))->delay($when)); 

.env:

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=database
SESSION_DRIVER=file
SESSION_LIFETIME=120

queue.php:

'connections' => [
    'sync' => [
        'driver' => 'sync',
    ],

    'database' => [
        'driver' => 'database',
        'table' => 'jobs',
        'queue' => 'default',
        'retry_after' => 90,
    ]
]

CustomerOrderItemStatusNotification:

use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;

class CustomerOrderItemStatusNotification extends Notification
{
    use Queueable;

The issue is that it is sending this immediately rather than waiting two minutes nor is it storing anything in the 'jobs' table.


Solution

implement class to shouldQueue interface

use Illuminate\Contracts\Queue\ShouldQueue;

class CustomerOrderItemStatusNotification extends Notification implements ShouldQueue
{
    use Queueable;


Answered By - Masood Khan
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing