PHP code example of ivan-grebnev / laravel-rabbitmq

1. Go to this page and download the library: Download ivan-grebnev/laravel-rabbitmq 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/ */

    

ivan-grebnev / laravel-rabbitmq example snippets


...
'rabbitmq' => [
    'tasks' => [
        // parameters of concrete task
        'SomeSend' => [
            'exchange' => 'Some.Send.Exchange',
            'routing_key' => 'Any.Routing.Key',
        ],
        'SomeRecieve' => [
            'queue' => 'Some.Recieve.Queue',
            'job' => \App\Jobs\Exchange\RecieveJob::class,
        ]
    ],
    // here default parameters for all tasks
    'defaults' => [
        'worker_job' => \App\Jobs\Exchange\CustomWorkerJob::class,
        'exchange_type' => 'topic',
        'consume_no_ack' => true,
    ],
],
...

// config/queue.php
...
'rabbitmq' => [
    'tasks' => [
        'UsersSendTask' => [
            'exchange' => 'Site.Users',
        ],
        'UsersRecieveTask' => [
            'queue' => 'Site.Users',
            'job' => \App\Jobs\Exchange\UsersRecieveJob::class,
        ]
    ],
    'defaults' => [
        'worker_job' => \App\Jobs\Exchange\CustomWorkerJob::class,
    ],
],
...

UsersSendJob::dispatch()->onConnection('rabbitmq')->onQueue('UsersSendTask');
src/config/default.php
config/queue.php