下面的代码不起作用。我认为我做的一切都是正确的,但不知怎么的,我没有工作。
..。MyJob::dispatch($job)->onQueue('processing')->delay(Carbon::now()->addSeconds(30));...
MyJob.php
<?php
namespace App\Jobs;
use Illuminate\Bus\Queueable;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
class MyJob implements ShouldQueue
{
use InteractsWithQueue, Queueable, SerializesModels, Dispatchable;
public function __construct($job)
{
// I described a logging code here and yes, there was change, but then...
}
public function handle()
{
// I described a logging code here, but there wasn't change
}
}问题是dispatchNow()确实工作,但是延迟的分派没有工作。
我也正确地设置了.env (我猜)
.env文件..。
QUEUE_CONNECTION=database..。
config/Quee.php ..。
'default' => env('QUEUE_CONNECTION', 'sync'),..。
请帮帮我。任何建议都会很好。谢谢。
发布于 2022-04-25 19:48:32
诊断步骤;
config('queue')并检查队列设置是否与预期的相同
没有运行队列工作者的
php artisan queue:work运行队列工作器,延迟后,作业应该运行。发布于 2022-07-19 14:24:06
您可以按照上面的建议尝试清除缓存。此外,还尝试重新启动队列。
php artisan queue:restart至于队列:工作问题。是的,如果您希望队列永久运行,那么使用监督器是一个很好的选择。示例配置如下所示。
[program:my-laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /path/to/project/artisan queue:work --queue=QUEUE_NAME--sleep=1 --tries=1
autostart=true
autorestart=true
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/log/file.loghttps://stackoverflow.com/questions/71996184
复制相似问题