I turned on listening with the command: php artisan queue:listen
This is the handle method in my job class
<code>public function handle() { $res1 = DB::table('log')->insertGetId( ['op' => 1] ); }</code>
Just insert a piece of data.
Call in controller
<code>class IndexController extends Controller { public function register() { $this->dispatch((new ProcessRegister(1))->onQueue('register')); echo "下单成功!"; } }</code>
The Redis service has been started. After accessing http://localhost/test, I found that there is no data in the database. . .
I turned on listening with the command: php artisan queue:listen
This is the handle method in my job class
<code>public function handle() { $res1 = DB::table('log')->insertGetId( ['op' => 1] ); }</code>
Just insert a piece of data.
Call in controller
<code>class IndexController extends Controller { public function register() { $this->dispatch((new ProcessRegister(1))->onQueue('register')); echo "下单成功!"; } }</code>
The Redis service has been started. After accessing http://localhost/test, I found that there is no data in the database. . .
Added a special group to solve the problem. You should use php artisan queue:listen --queue=register
--queue to listen to the specific queue
It is recommended not to use it
<code>->onQueue('register'))</code>
, then
<code>php artisan queue:listen</code>
Nor add --queue
There are only a few tasks that need to be executed in the background, so there is no need to name them, and if you misspell a word, another weird bug will be created.