用命令开启了监听了: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。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号