我尝试做所有这些:
尝试1:
DispatchWpAutoNewTaskJob::dispatch($payload)->delay(now()->addSeconds(10));
尝试2:
$when = now()->addSeconds(10); dispatch(new DispatchWpAutoNewTaskJob($payload))->later($when);
尝试3:
dispatch(new DispatchWpAutoNewTaskJob($payload))->delay(now()->addSeconds(10));
但是它都会返回类似这样的错误:
[2023-10-25 20:13:09] local.ERROR: Call to undefined method App\Jobs\DispatchWpAutoNewTaskJob::delay() {"exception":"[object] (Error(code: 0): Call to undefined method App\\Jobs\\DispatchWpAutoNewTaskJob::delay() at /www/wwwroot/zz.com.test/vendor/laravel/framework/src/Illuminate/Foundation/Bus/PendingDispatch.php:98) [stacktrace] #0 /www/wwwroot/zz.com.test/app/Http/Controllers/Api/WpAutoWebhookController.php(63): Illuminate\\Foundation\\Bus\\PendingDispatch->delay() #1 /www/wwwroot/zz.com.test/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(54): App\\Http\\Controllers\\Api\\WpAutoWebhookController->handleWebhook()
Laravel 版本: Laravel 框架 9.52.10
尝试1:
DispatchWpAutoNewTaskJob::dispatch($payload)->delay(now()->addSeconds(10));
尝试2:
$when = now()->addSeconds(10); dispatch(new DispatchWpAutoNewTaskJob($payload))->later($when);
尝试3:
dispatch(new DispatchWpAutoNewTaskJob($payload))->delay(now()->addSeconds(10));
我期望作业会延迟调度,并且应该是非阻塞的。我已经设置了 redis 并且它正在工作。我唯一的问题是延迟。
请注意,作业内的代码实际上正在运行,但没有任何延迟。我想添加非阻塞延迟