php - 拉拉维尔 5.6。将状态附加到队列工作线程

标签 php laravel laravel-5.6 laravel-queue

是否可以以某种方式将状态附加到队列工作线程。

例如

queue:work <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="c2efefadacefa3a1a1adb7acb6ffb1adafa782afa3abaeeca1adaf" rel="noreferrer noopener nofollow">[email protected]</a>

然后使用这个--on-account工作中的变量。

基本想法是,由于某些限制,每个帐户只能有一名工作人员。而且它永远不会改变。因此,扩展的唯一方法是添加更多帐户。

每个作业都可以使用任何帐户进行处理。

我会接受

It's not possible because of XYZ. Use this technique to achieve the same result.

也作为答案。

附注

不是 Running artisan queue:work with additional arguments 的重复因为他的回答不适合我的情况。

最佳答案

使用环境变量怎么样?

您将按如下方式运行队列:

导出帐户=“some@email”;php artisan 队列:工作 然后,在 worker 中你会

$account getenv('帐户');

另一个想法可能是使用连接功能:

https://laravel.com/docs/5.7/queues#running-the-queue-worker

引用

You may also specify which queue connection the worker should utilize. The connection name passed to the work command should correspond to one of the connections defined in your config/queue.php configuration file:

php artisan queue:work redis

You may customize your queue worker even further by only processing particular queues for a given connection. For example, if all of your emails are processed in an emails queue on your redis queue connection, you may issue the following command to start a worker that only processes only that queue:

php artisan queue:work redis --queue=emails

至少就 Laravel 而言,这可能是最干净的解决方案。 除非我错过了到底是什么问题。

关于php - 拉拉维尔 5.6。将状态附加到队列工作线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52533952/

相关文章:

php - Laravel 5.6 奇怪的行为 - Laravel 在重命名后看不到 Controller

javascript - 如何从 API 获取未见过/未读的通知计数?

javascript - 如何从 Laravel 4.2 中的 View 脚本调用模型函数

php - Symfony\Component\Debug\Exception\FatalThrowableError类'Buno\Readr\ReadrServiceProvider'未找到

php - Laravel 5 - 迁移中的复合键索引

php - laravel join 查询为两个不同的数据返回两个相同的 id

javascript - 表单提交时在浏览器中显示加载

php - 对于 Mysql 和 PHP 中的 UTF-8,我真的需要从 VARCHAR 切换到 VARBINARY 吗?

mysql - 使用 laravel eloquent 检索多对多关系

Laravel 5.6 Api - 搜索、排序和过滤数据列表