I am studying Job dispatching from here

Problem

我读到每个连接都有告诉队列名称的队列参数.问题是:我如何设置发送低、中或高优先级邮箱的优先级?

Cmd prompt

I am using command: php artisan queue:listen to process job.

What I tried?

php artisan queue:work --queue=high,default

但如果连接的队列参数has值不高,则此代码永远不会工作

Default Queue Driver

'default' => env('QUEUE_DRIVER', 'database'),

Queue Connections

'connections' => [

    'Register' => [
        'driver'        =>  'database',
        'table'         =>  'tbljobs',
        'queue'         =>  'low',
        'retry_after'   =>  5,
    ],

    'ForgotPassword' => [
        'driver'        =>  'database',
        'table'         =>  'tbljobs',
        'queue'         =>  'low',
        'retry_after'   =>  5,
    ],

],

.env

QUEUE_DRIVER=Register

Controller Code for Register email

$job = (new SendActivationEmail($Data))
        ->onConnection('Register');
dispatch($job);

Controller Code for Reset Password

$job = (new SendResetPasswordEmail($this->tokens->create($user), $user))
        ->onConnection('ForgotPassword');
dispatch($job);

推荐答案

请注意Laravel's queue documentation中的Connections Vs. Queues条,据我所知,这适用于除SQS之外的所有队列驱动程序.

在开始使用Laravel队列之前,重要的是

Note that each connection configuration example in the queue configuration file contains a queue attribute. This is the default queue that jobs will be dispatched to when they are sent to a given connection. In other words, if you dispatch a job without explicitly defining which queue it should be dispatched to, the job will be placed on the queue that is defined in the queue attribute of the connection configuration:

实际上,您将在config/queues.php文件中注册一个队列连接,如果没有提供另一个队列,default参数将只是默认情况下作业(job)调度到的队列.

Vitaly's answer above would be the correct approach to the problem (consolidate to a single connection with a default queue) then adjust your jobs to get sent to different queues if required. This is some important (I think) context to how how queue configuration works.

Laravel相关问答推荐

@vite指令在使用laravel vite构建后导致错误

在 React 中将属性从一个组件传递到另一个组件

分页计数(*)查询问题

我的共享主机上的每个帖子请求都出现 503 服务不可用

未定义防护 [api] 的授权驱动程序 [api]

如何在 Laravel 中使用 Vue 路由?

Laravel where 子句只返回一个数据库条目

错误try 访问 null 类型值的数组偏移量laravel 5.8.26 Php 7.4.2

在 Laravel 5 中添加新配置文件不起作用

允许的内存大小 134217728 字节用尽(试图分配 20480 字节) Laravel

Laravel 5.1 如何在Blade 文件上使用 {{ old('') }} 助手进行无线电输入

Laravel:Blade foreach 循环 bootstrap 列

将 Laravel MYSQL 更改为 utf8mb4 以在现有数据库中支持表情符号

如何访问 Carbon 对象类型?

脚本 php artisan clear-compiled 处理 pre-update-cmd 事件返回错误(Laravel 4.1 升级)

将 Laravel 集合排序为 ID 数组

将参数传递给 Laravel 中的中间件

Laravel 4:分析器在哪里?

Laravel 如何在 Eloquent 模型中添加自定义函数?

Laravel 5.3 - 用户Collection 的单一通知(关注者)