Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

James_Bhatta's avatar

Should I queue listener or notifications?

Currently I am firing an event on while updating a model using listener and the event is being listened by many listeners. Inside listener I am sending notifications to multiple users via multiple channels. Right now I am queuing the notifications only. Is it a good approach? Considering that I want the update process to be completed successfully even the notifications failed to send or some sort of exception occurred in notifications.

0 likes
8 replies
bobbybouwmann's avatar

Well, it depends. If your listener itself is doing a heavy task you could queue them as well. If your listener is only performing the notification you might not have to queue it. You can also queue both, so the listener and the notification. Like I said it depends on how heavy the task is and what your needs are ;)

2 likes
James_Bhatta's avatar

Will there be any delay in sending notifications if I queue both listeners and notifications?

James_Bhatta's avatar

@bobbybouwmann I was waiting for you reply. You answers in Laracasts has helped me out a lot. And this is the first time my answer is being replied by you. Thanks a lot. Please let me have the honor to chat with you a little more.

Snapey's avatar
Snapey
Best Answer
Level 122

make sure you @mention someone if you update your question and want a followup

Will there be a delay? It depends how backlogged your queue is .

If you are running at 500 jobs on your queue and it takes 3 minutes to get to your queued listener then a notification is created but goes to the back of the queue, by which time there may be a further 500 jobs queued, and another 3 minute delay.

The numbers are just examples of course

1 like
James_Bhatta's avatar

Oh so it is queued again which may take more time depending upon the josbs to be processed. Thanks @snapey

Snapey's avatar

If the listener just creates the notification then don't queue it (which is what Bobby said also)

bobbybouwmann's avatar

@james_bhatta Snapey is correct. It's just a new job in the queue that will be processed in order depending on your setup.

You can also have a priority queue to process notifications faster, but it sounds to me that this will do ;) You notification will be handled within 2 sec of handling your listener ;)

1 like

Please or to participate in this conversation.