@dana
To listen to all queues in Laravel, you can use the listen
method provided by the Laravel Queue
facade. Here's an example of how to use it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
use IlluminateSupportFacadesQueue; use IlluminateQueueEventsJobProcessed; use IlluminateQueueEventsJobProcessing; public function boot() { parent::boot(); Queue::before(function (JobProcessing $event) { // Code to execute before a job is processed }); Queue::after(function (JobProcessed $event) { // Code to execute after a job is processed }); } |
By using the before
and after
methods provided by the Queue
facade, you can listen to all queues and execute custom logic accordingly. For example, you can log information, send notifications, or perform any other desired actions.