PHP code example of joaoluizjoaquim / laravel-nsq

1. Go to this page and download the library: Download joaoluizjoaquim/laravel-nsq library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

joaoluizjoaquim / laravel-nsq example snippets


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);
        ...
    }
}

// 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);

php artisan make:job NsqTestJob

php artisan queue:work nsq --sleep=3 --tries=3 --timeout=500  --job=App\\Jobs\\NsqTestJob