PHP code example of elielelie / laravel-activemq

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

    

elielelie / laravel-activemq example snippets


use App\Jobs\ProcessOrder;

// Dispatch to the default queue
ProcessOrder::dispatch($order);

// Dispatch to a specific queue
ProcessOrder::dispatch($order)->onQueue('orders');

// Delay job execution by 10 minutes
ProcessOrder::dispatch($order)->delay(now()->addMinutes(10));

use Illuminate\Support\Facades\Queue;

$isConnected = Queue::connection('activemq')->healthCheck();

if (!$isConnected) {
    // Handle connection failure
}

'environments' => [
    'production' => [
        'activemq-default' => [
            'connection' => 'activemq',
            'queue' => ['default'],
            'balance' => 'simple',
            'processes' => 3,
        ],
        'activemq-emails' => [
            'connection' => 'activemq', 
            'queue' => ['email'],
            'balance' => 'auto',
            'processes' => 2,
            'maxProcesses' => 5,
        ],
        'activemq-notifications' => [
            'connection' => 'activemq',
            'queue' => ['notifications'],
            'balance' => 'simple', 
            'processes' => 1,
        ],
    ],
],
$ php artisan vendor:publish --provider="Elielelie\ActiveMQ\ActiveMQServiceProvider"