定制 l2t/laravel-pubsub-queue 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

l2t/laravel-pubsub-queue

最新稳定版本:1.0.0

Composer 安装命令:

composer require l2t/laravel-pubsub-queue

包简介

Laravel Pub/Sub Queue Support

README 文档

README

Laravel Pub/Sub Queue

If you want to get support of pub/sub queue driver in laravel this package is ideal for your needs.

Follow installation below or on my blog: https://learn2torials.com/a/laravel9-pub-sub-integration

How to install this package

# install composer dependency
composer require l2t/laravel-pubsub-queue


# go to your laravel config/queue.php file and add following block
'connections' => [
    
    // other settings
    
    'pubsub' => [
        'retries' => 3,
        'driver' => 'pubsub',
        'request_timeout' => 60,
        'queue' => env('PUBSUB_DEFAULT_QUEUE'),
        'project_id' => env('GOOGLE_CLOUD_PROJECT'),
        'queue_prefix' => env('PUBSUB_QUEUE_PREFIX', ''),
        'keyFilePath' => storage_path(env('GOOGLE_APPLICATION_CREDENTIALS')),
    ],    
]

# let's create a directory in storage folder
mkdir -p storage/secrets

# add following new env variables in .env file
# google credentials
PUBSUB_DEFAULT_QUEUE=<topic-name>
GOOGLE_CLOUD_PROJECT=<project-name>
GOOGLE_APPLICATION_CREDENTIALS=secrets/<google-credentials>.json

# enable pub/sub queue driver in .env
QUEUE_CONNECTION=pubsub

How to dispatch job to pub/sub queue

# queue jobs to default topic
dispatch(new PubSubJob());

# queue jobs to specific topic
dispatch(new PubSubJob())->onQueue(env('PUBSUB_CUSTOM_QUEUE'));

# process the topic in pubsub
php artisan queue:work pubsub

# process the topic 
php artisan queue:work --queue=<some-topic>

That is it now you should be able to use pub/sub queues in your laravel project.

统计信息

  • 总下载量: 10.17k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-05-13