Laravel 4: Queues and Multiple Listeners

If I run Beanstalk with Supervisor on a server with a Laravel 4 application, and I want it to process all the queues asynchronously - as much as it can at the same time - can I have several listeners working at the same time? Will they be smart enough not to β€œtake” the same subject from the queue, or will they all achieve the same thing at the same time and thus will not work the way I want? In short, I want to use queues to process several tasks at a time - can this be done?

php artisan queue:listen && php artisan queue:listen && php artisan queue:listen 
+6
source share
1 answer

In short, I want to use queues to process several tasks at a time - can this be done?

In short - yes, it can be done. Each work occupied by the worker is blocked until it is released. This means that other workers will receive different jobs for processing.

IMO it is better to configure Supervisor to run several queue:work commands. It will take only one job, process it and stop execution. It is not recommended to run PHP scripts in an infinite loop (as queue:listen does), because after some time they may have memory problems (leaks, etc.).

You can configure Supervisor to restart ready-made workers.

+5
source

All Articles