jiyis / laravel-nsq
Nsq driver for Laravel Queue
Installs: 3 959
Dependents: 0
Suggesters: 0
Security: 0
Stars: 9
Watchers: 6
Forks: 4
Open Issues: 1
Requires
- php: >=7.0
- illuminate/database: ^5.1
- illuminate/queue: ^5.1
- illuminate/support: ^5.1
Requires (Dev)
- illuminate/events: ^5.1
- mockery/mockery: ~1.0
- phpunit/phpunit: ~7.0
Suggests
- ext-swoole: Event-driven asynchronous & concurrent & coroutine networking engine with high performance for PHP.
This package is not auto-updated.
Last update: 2024-12-22 08:39:18 UTC
README
NSQ client for laravel
Requirements
Installation
pecl install swoole
composer require jiyis/laravel-nsq
Usage
Set env
NSQSD_URL=127.0.0.1:4150
NSQLOOKUP_URL=127.0.0.1:4161
# If it is multiple, please separate them with ","
NSQSD_URL=127.0.0.1:4150,127.0.0.1:4250
Create Job
php artisan make:job NsqTestJob
you need set two property. public $topic;
public $channel;
class NsqTestJob implements ShouldQueue { use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; public $topic = 'test'; public $channel = 'web'; public function handle() { $client = $this->job->getCurrentClient(); $payload = json_decode($this->job->getMessage(), true); ... } }
Publish
// the data you want to be publish $str = [ 'message' => 'this is a message', 'user_id' => 1 ]; // not supported dispatch Queue::connection('nsq')->push(new NsqTestJob, $str);
Subscribe
php artisan queue:work nsq --sleep=3 --tries=3 --timeout=500 --job=App\\Jobs\\NsqTestJob