是否可以以某种方式将状态附加到队列工作线程。
例如
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/