简体   繁体   English

如何使用 Google Cloud Pub/Sub 作为 Laravel 队列驱动程序

[英]How to use Google Cloud Pub/Sub as Laravel Queue Driver

So I was following this tutorial on how to use pub sub as Laravel queue driver.所以我正在关注本教程,了解如何使用 pub sub 作为 Laravel 队列驱动程序。 but I am stuck as I was trying to run the worker with php artisan queue:work --queue=clcej which showed error但是当我试图使用 php artisan queue:work --queue=clcej 运行工作人员时,我被卡住了,这显示了错误

No connector for [pubsub]

this is the lines I added at my config/queue.php这是我在 config/queue.php 中添加的行

        'default' => env('QUEUE_CONNECTION', 'pubsub'),
        'pubsub' => [
            'driver' => 'pubsub',
            'queue' => 'clcej',
            'queue_prefix' => env('PUBSUB_QUEUE_PREFIX', ''),
            'project_id' => env('GOOGLE_CLOUD_PROJECT_ID', 'ciputra-nusantara'),
            'retries' => 3,
            'request_timeout' => 60,
        ],

I am still confused because in the tutorial there is no step where I have to set up the pub/sub in GCP我仍然很困惑,因为在教程中没有我必须在 GCP 中设置 pub/sub 的步骤

or is there easier and efficient way to run a queue worker on a serverless environment ?还是有更简单有效的方法在无服务器环境中运行队列工作者?

Cloud Pub/Sub requires messages to be published to “topics” and then delivered to consumers using “subscriptions”. Cloud Pub/Sub 要求将消息发布到“主题”,然后使用“订阅”传递给消费者。 Our overview documentation can help you understand topic and subscription concepts.我们的概述文档可以帮助您了解主题和订阅概念。 Both topics and subscriptions need to be created before they can be used.主题和订阅都需要先创建才能使用。

The configuration section of the library docs indicate that you may need to change the queue section of your configuration to be 'queue' => env('PUBSUB_QUEUE', 'clcej'), .库文档的配置部分表明您可能需要将配置的queue部分更改为'queue' => env('PUBSUB_QUEUE', 'clcej'),

Alternatively our quickstart can help you create topics/subscriptions on the Google Cloud console.或者,我们的快速入门可以帮助您在 Google Cloud 控制台上创建主题/订阅。

Or, you may use the gcloud CLI and follow the steps outlined in the gcloud quickstart to:或者,您可以使用gcloud CLI并按照gcloud 快速入门中列出的步骤执行以下操作:

Create a topic with the ID my-topic创建一个 ID 为my-topic

gcloud pubsub topics create my-topic

Create a subscription with the ID my-sub and attach it to my-topic:创建一个 ID 为my-sub的订阅并将其附加到 my-topic:

gcloud pubsub subscriptions create my-sub --topic=my-topic

You can retry the tutorial after creating the topic/subscription.您可以在创建主题/订阅后重试本教程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM