如何从Laravel中的作业ID获取排队的作业? [英] How to get the queued job from job ID in Laravel?
本文介绍了如何从Laravel中的作业ID获取排队的作业?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有什么方法可以从Laravel中的作业ID中获取排队的作业吗?将作业添加到队列时,我存储了作业ID.稍后在某个时间点(在队列中处理该作业有延迟),我想从队列中删除该作业.如果可以使用作业ID在队列中获取该作业,则可以使用delete()
方法将其删除.
Is there any way to get the queued job from the job ID in Laravel? While adding the job to the queue, I store the job ID. Later at some point of time (there is a delay to process the job in the queue), I want to remove the job from the queue. If I can get the job on the queue using the job ID, I can use delete()
method to remove it.
推荐答案
我将此代码用于laravel 5.5:
I use this code for laravel 5.5 :
use Illuminate\Contracts\Bus\Dispatcher;
$job = ( new JOB_CLASS() )->onQueue('QUEUE_NAME')->delay('DELAY');
$id = app(Dispatcher::class)->dispatch($job);
这篇关于如何从Laravel中的作业ID获取排队的作业?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文