-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CMQ多个队列支持 #8
Comments
是支持多个队列的。 如果是 相同地域 和 账号,可以直接指定队列名称; 如果是 不同地域 或 账号,需要在 'connections' => [
//...
'your-connection-name' => [
'driver' => 'cmq',
'secret_key' => 'your-secret-key',
'secret_id' => 'your-secret-id',
'queue' => 'your-queue-name',
'options' => [
'queue' => [
'host' => 'https://cmq-queue-region.api.qcloud.com',
'name' => 'your-queue-name',
'polling_wait_seconds' => 0, // 0-30seconds
],
'topic' => [
'enable' => false,
'filter' => 'routing', //routing or msgtag
'host' => 'https://cmq-topic-region.api.qcloud.com',
'name' => '',
],
],
];
//...
]; 分派 Job::dispatch()->onConnection('your-connection-name')->onQueue('queue-name-1');
Job::dispatch()->onConnection('your-connection-name')->onQueue('queue-name-2');
dispatch((new Job)->onConnection('your-connection-name')->onQueue('queue-name-1'));
dispatch((new Job)->onConnection('your-connection-name')->onQueue('queue-name-2')); 在 <?php
namespace App\Jobs;
class ProcessPodcast implements ShouldQueue
{
/**
* The name of the connection the job belongs to.
*/
protected $connectionName = 'your-connection-name';
/**
* The name of the queue the job belongs to.
*
* @var string
*/
protected $queue = 'your-queue-name';
} 处理指定的连接和队列
|
感谢您的回复,几个队列都在一个账号、同一地域下,唯有 queue name 不同 |
还是指:php artisan queue:work {connection-name} --queue={queue-name} |
上面的问题已经解决,感谢您。 |
{
"displayName":"App\\Jobs\\TestJob",
"job":"Illuminate\\Queue\\CallQueuedHandler@call",
"maxTries":null,
"timeout":null,
"data":{
"commandName":"App\\Jobs\\TestJob",
"command":"O:16:\"App\\Jobs\\TestJob\":4:{s:6:\"*job\";N;s:10:\"connection\";N;s:5:\"queue\";N;s:5:\"delay\";N;}"
}
} 后续会支持自定义 |
感谢,后来琢磨出来了,laravel 会默认调用CallQueuedHandler 的 fire 函数,像上面如果指定了 call 函数,那CallQueuedHandler必须声明一个 call 函数 多谢指点,已经顺利运行 |
作者您好,如果我需要从 CMQ 的多个队列中获取数据,在配置文件中CMQ_QUEUE 配置项该怎么填写?
是否支持多个队列?
The text was updated successfully, but these errors were encountered: