'Why Notification is queued in redis without implements ShouldQueue?

In laravel 9 app I use queues with redis and for that in notifications which must be queued I wrote :

class CurrencyRatesImportRunNotification extends Notification  implements ShouldQueue  // IT IS QUEUED
{
    use Queueable;



    public function __construct(
    ) {
    ...
    }

    public function via($notifiable)
    {
        return ['mail'];
    }

and these emails are sent at the moment when I run in console :

php artisan queue:work

But I also have different notifications, which must be sent at immediately and event must be broadcasted to notify in the app with pusher-js, so this notification has :

class ContactUsCreatedNotification extends Notification   // IT HAS NO ShouldQueue here
{
    use Queueable;
    public function __construct(string $title, string $content_message, int $user_id)
    {
    ...
    }

    public function via($notifiable)
    {
        return ['mail', 'broadcast'];
    }

as in .env file I have :

QUEUE_CONNECTION=redis
REDIS_CLIENT=predis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379


BROADCAST_DRIVER=log  // later I will replace it with pusher
CACHE_DRIVER=file
FILESYSTEM_DISK=local
SESSION_DRIVER=database
SESSION_LIFETIME=120

I expected to see Broadcasting events in log but it does not happen. In phpRedisAdmin I see these Broadcasting events and only after I run

php artisan queue:work

I see in logs files lines like :

[2022-05-13 06:51:10] local.INFO: Broadcasting [Illuminate\Notifications\Events\BroadcastNotificationCreated] on channels [private-App.Models.User.1] with payload:
{
    "title": "Contact us and we will review your message",
    "content_message": "Contact us and we will review your message",
    "user_id": 1,
    "id": "ea1c4896-9460-495c-bc9a-6a8fd0547fd3",
    "type": "App\\Notifications\\ContactUsCreatedNotification",
    "socket": null
}

for any event.

Why ContactUsCreatedNotification is queued in redis? as i has no implements ShouldQueue ?

"laravel/framework": "^v9.6.0",
"predis/predis": "^1.1",
"pusher/pusher-php-server": "^7.0",

"pusher-js": "^7.1.0-beta",

Thanks!



Solution 1:[1]

Remove the Queueable trait from ContactUsCreatedNotification and everything will be ok.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Emil Georgiev