jiyis/laravel-nsq
Laravel Nsq Client
NSQ client for laravel
Requirements
| Dependency | Requirement |
|---|---|
| PHP | >= 7.1.0 |
| Swoole | The Newer The Better No longer support PHP5 since 2.0.12 |
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
Related Packages
doctrine/dbal
Powerful PHP database abstraction layer (DBAL) with many features for database s...
644,549,754
9,698
laravel/serializable-closure
Laravel Serializable Closure provides an easy and secure way to serialize closur...
423,477,751
607
nunomaduro/collision
Cli error handling for console/command-line PHP applications.
403,217,078
4,664
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| 1.0.2 | >=7.0 | ^5.1 | MIT | |
| 1.0.1 | >=7.0 | ^5.1 | MIT | |
| 1.0.0 | >=7.0 | ^5.1 | MIT |