Chris
Chris

Reputation: 4446

Specifying queue name for Laravel notifications

I'm building a SAAS and I want each tenant to have their own queue for notifications. I have a notification class that implements Illuminate\Contracts\Queue\ShouldQueue and I send the notification like this

$user->notify($notification);

But I haven't found a way to specify the queue that I want the notification to be pushed to. I know that jobs can be pushed to specific queues with onQueue:

ProcessPodcast::dispatch($podcast)->onQueue('tenant1');

But is it possible to do something like this for queueable notifications as well?

Upvotes: 1

Views: 2078

Answers (1)

miken32
miken32

Reputation: 42736

Since your notification should use the Illuminate\Bus\Queueable trait you can simply set the $queue property of the object. There's a helper function for it:

$notification->onQueue('tenant1');
$user->notify($notification);

Upvotes: 2

Related Questions