简体   繁体   中英

Laravel 4: Queues and Multiple Listeners

If I am running Beanstalk with Supervisor on a server with a Laravel 4 application, and I want it to process all queues asynchronously -- as many as it can at the same time -- can I have multiple listeners running at the same time? Will they be smart enough to not "take" the same to-do item from the queue, or will they all reach for the same one at the same time, and thus not work in the way I'm wanting? In short, I want to use Queues to process multiple tasks at a time -- can this be done?

php artisan queue:listen && php artisan queue:listen && php artisan queue:listen

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

In short - yes it can be done. Every job taken by a worker is locked until it's release. It means that other workers will get different jobs to process.

IMO it's better to configure Supervisor to run multiple queue:work command. It will take only one job, process it and stop execution. It's not encouraged to run PHP scripts in a infinite loop (as queue:listen does), because after some time they can have memory issues (leaks etc).

You can configure Supervisor to re-run finished workers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM