用命令开启了监听了(本文来)源gaodaimacom搞#^代%!码&网(
搞gaodaima代码
:php artisan queue:listen
这是我job类中的handle方法
<code>public function handle() { $res1 = DB::table('log')->insertGetId( ['op' => 1] ); }</code>
就是插入一条数据嘛。
在控制器中调用
<code>class IndexController extends Controller{ public function register() { $this->dispatch((new ProcessRegister(1))->onQueue('register')); echo "下单成功!"; }}</code>
Redis服务已经开启了,访问http://localhost/test后,发现数据库什么数据也没有。。。
回复内容:
用命令开启了监听了:php artisan queue:listen
这是我job类中的handle方法
<code>public function handle() { $res1 = DB::table('log')->insertGetId( ['op' => 1] ); }</code>
就是插入一条数据嘛。
在控制器中调用
<code>class IndexController extends Controller{ public function register() { $this->dispatch((new ProcessRegister(1))->onQueue('register')); echo "下单成功!"; }}</code>
Redis服务已经开启了,访问http://localhost/test后,发现数据库什么数据也没有。。。
加了专门的群解决了,应该用php artisan queue:listen –queue=register
–queue这个监听具体的队列
建议还是别用
<code>->onQueue('register'))</code>
,然后
<code>php artisan queue:listen</code>
也不加 --queue
本来就没几个要后台执行的任务,没必要命名,而且万一拼错单词,那就又创造一个诡异的bug。