定制 maxzhang666/laravel-nsq 二次开发

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

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

maxzhang666/laravel-nsq

Composer 安装命令:

composer require maxzhang666/laravel-nsq

包简介

Laravel NSQ

README 文档

README

Laravel package for NSQ queue manager that uses Laravel's API

dep func

pcntl_sigprocmask

Installation

First, require the package using Composer:

composer require merkeleon/laravel-nsq

  1. Add new queue job as described in Laravel's manual:

php artisan make:job <JobName> Edit this file according to Laravel's rules

  1. Set queue driver to NSQ

QUEUE_DRIVER=nsq

  1. Set env options for NSQ servers:

NSQSD_URL=127.0.0.1:4150 IP and port for Nsq daemon

NSQLOOKUP_URL=127.0.0.1:4161 IP and port for Nsq lookup daemon

Use comma as separator if you want to use several servers:

NSQSD_URL=127.0.0.1:4150,127.0.0.1:4151,127.0.0.1:4152

Example

Job class

<?php

namespace App\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Support\Facades\Config;

class CoolJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    public function __construct(...$args)
    {
        $this->queue = 'my-cool-jobs';
        
        // $args code
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        // do the job
    }
}

Some where in a code

<?php

... code ...

// Push timed task in the queue
CoolJob::dispatch(...$any_args);

... code ...

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-06-20