如何在Lumen 5.5中将作业分配到特定队列 [英] How to dispatch a Job to a specific queue in Lumen 5.5

查看:71
本文介绍了如何在Lumen 5.5中将作业分配到特定队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在标准作业中,我使用此方法调度作业:

In standard a job I use this method to dispatch a Job:

dispatch(new PurchaseJob($trxId, $method, $params));

接下来,我想调度另一个Job来发送电子邮件,但是我想将其拆分到另一个单独的队列中. 根据我在Laravel 5.5文档上的阅读,我可以做到这一点:

Next I want to dispatch another Job to send email, but I want to split it to another separate queue. From what I read on Laravel 5.5 docs I could do this:

SendEmailJob::dispatch($userEmail)->onQueue('send_email');

但它在Lumen 5.5上似乎不起作用.

But it does not seems to work on Lumen 5.5.

我该怎么做才能完成这项工作,或者文档中未说明其他任何方法?

What could I do to make this work or is there any other method that are not stated in the docs?

推荐答案

我只是设法找到一种在Lumen 5.5中分配具有指定名称的队列的方法.

I just managed to find a way to dispatch the queue with the specified name in Lumen 5.5.

public function toMail($notifiable)
{
    $job = (new SendFriendRequestEmail($notifiable))->onQueue('email');
    dispatch($job);
}

文章可能会帮助您了解更多信息

May be this article will help you understand more

这篇关于如何在Lumen 5.5中将作业分配到特定队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆