延迟流明上的作业队列

sha*_*nex 1 lumen laravel-7

我有一个关于 Lumen 7 的项目,其中包括很多队列,但我不能推迟工作。

这就是我派遣工作的方式:

dispatch(new NotifyJob($user, $template));
Run Code Online (Sandbox Code Playgroud)

但是当我添加这个时

dispatch(new NotifyJob($user, $template))->delay(now()->addMinutes(10));
Run Code Online (Sandbox Code Playgroud)

我收到这个错误

"Call to undefined method Laravel\\Lumen\\Bus\\PendingDispatch::delay()"
Run Code Online (Sandbox Code Playgroud)

这样做 EmailJob::dispatch($user, $template); 让我Undefined method dispatch

我就是无法推迟上班。

小智 6

您可以使用“队列”外观。

例如:

Queue::later(Carbon::now()->addMinutes(10),new GetCityInfoDelay());
Run Code Online (Sandbox Code Playgroud)