Some problems about the use of laravel queues

due to business needs, I need to execute several different push notifications in one method. After thinking about it, I want to execute it through the queue. Now there are some questions that I need your bosses to point out:

how to write a document:
php artisan queue:work database

1. Can work be understood as a thread when running a queue? Can I open multiple connections? I mean, write like this, if not, can you use two connections? How to configure it?

 php artisan queue:work  database,databse1

2. Are queues executed in parallel?

Can the asynchronous queue of

3.laravel be understood as opening a separate thread and executing all queues in that thread instead of creating a separate thread for each thread? If I want to use a separate thread for each queue, can I only use swoole services?

Mar.28,2021

  • the first question, can work understand bit threads? No, the php artisan queue:work here is just a process. The tasks in the queue are executed sequentially. Only one task in a process is processed at the same time. Only when this is finished will the next task be processed.

    therefore, in order to improve execution efficiency, it is common to start multiple such work processes to process, such as using supervisor to manage the process.

    cannot specify two connection in one php artisan queue:work . Generally speaking, if there are multiple different connection, then start multiple php artisan queu:work database processes to listen for different connection.

  • second question, are queues executed in parallel? For a single php artisan queue:work , all the tasks are executed serially, and you can specify them to listen to different queues using the -- queue parameter, so you need to create a php artisan queue:work-- queue queueName process for each queue, so that the queues can process
  • in parallel.
  • the third problem is that asynchronous queues in Laravel cannot be understood as threads. They are all processes. It is recommended to use supervisor to manage multiple Laravel queue processes.

this answer can be more than processes : https://codeshelper.com/q/10.

"

this article can also be read: https://laravel-china.org/art.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ead60c-214b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ead60c-214b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?